标准 大 超大巨大
温馨提示:该条问答的文字/图片中可能存在风险信息,请注意识别,谨防上当受骗!
VBA中 Dim 来自intRow As Integer和Dim strXh As String是什么意思?急!

用户头像name1号

2016-04-13

具体代码如下:Subadd()DimintRowAsIntegerDimstrXhAsStringSheets("供方名录").ActivateIfstrStatus="查询"ThenintRow=intCurrentRowElseSheets("供方名录").Range("A8").Select'获取... 具体代码如下:
Sub add()
Dim intRow As Integer
Dim strXh As String
Sheets("供方名录").Activate
If strStatus = "查询" Then
intRow = intCurrentRow
Else
Sheets("供方名录").Range("A8").Select
'获取员工花名册已有数据行数
intRow = ActiveCell.CurrentRegion.Rows.Count
strXh = Cells(intRow, 1) '取得最后编号
'按规则产生新的编号
strXh = "J" & Format(Right(strXh, 3) + 1, "000")
strXh = "J" & Format(Right(strXh, 4) + 1, "000")
'strXh = "J" & UserForm(Right(strXh, 3) + 1, "000")
'strXh = "J" & UserForm(Right(strXh, 4) + 1, "000")
intRow = intRow + 1
'将用户窗体上的数据填充到“供方名录”的新行上
Cells(intRow, 1) = strXh
End If 展开

满意答案

gf520okli
LV8
推荐于2016-04-14
Dim intRow As Integer 表示定义intRow 为整形变量
Dim strXh As String 表示 定义strXh为字符型变量

追问 : 现在调试不好,出错呀,提示"strXh = "J" & Format(Right(strXh, 4) + 1, "0000")"类型不匹配!

追答 : 你的Right(strXh, 4) + 1是不对的,因为:right(strXh,4)含有字符"J",不能+1的

00

您可能感兴趣的内容

相关问题

查看更多相关问题