错误1004,表单名称存储在数组中

时间:2014-02-17 18:49:46

标签: excel-vba vba excel

我在这个命令中遇到错误

d = Worksheets(A(i)).Cells(B(j), l) + d

我在表格A(i)中存储了工作表的名称 数组B(j)具有整数值。 我已经将两个数组一起声明为d整数。

提前致谢,

请找到以下代码

Sub checksum()
Dim A(50) As String
Dim B(5) As Integer
Dim i As Integer, j As Integer, d As Integer, k As Integer, p As Integer, l As Integer, s As Integer
s = 1
A(1) = "TREND M S&G"
A(2) = "TREND M RAZORS"
A(3) = "TREND M RZ ACC"
A(4) = "TREND M GROOM"
A(5) = "TREND BODY GROOM"
A(6) = "TREND Multi"
A(7) = "TREND BRDM"
A(8) = "TREND PRCSN"
A(9) = "TREND M H CLIP"
A(10) = "TREND PTB&A"
A(11) = "TREND rch"
A(12) = "TREND batt"
A(13) = "TREND refills"
A(14) = "TREND BABY"
A(15) = "TREND BREAST FEED"
A(16) = "TREND breast pad"
A(17) = "TREND breast pumps"
A(18) = "TREND REUSABLE"
A(19) = "TREND DISPOSABLE"
A(20) = "TREND TODDLER"
A(21) = "TREND TODDLER C&P"
A(22) = "TREND FEED ACCESS"
A(23) = "TREND SOOTHING"
A(24) = "TREND P&H"
A(25) = "TREND TEETHERS"
B(1) = 3
B(2) = 6
B(3) = 9
B(4) = 12
ThisWorkbook.Sheets.Add After:=Sheets(Worksheets.Count), Count:=1, Type:=xlWorksheet
For i = 1 To 25
Worksheets(Worksheets.Count).Cells(i, 1) = A(i)
For j = 1 To 4
d = 0

If i > 10 Then k = 54 And p = 70
If i < 11 Then k = 56 And p = 66



For l = k To p
d = Worksheets(A(i)).Cells(B(j), l) + d
Next l

If d = 100 Then Worksheets(Worksheets.Count).Cells(i, j + 1) = "Fine"
If d <> 100 Then Worksheets(Worksheets.Count).Cells(i, j + 1) = "Error"



Next j
Next i
End Sub

0 个答案:

没有答案