gpt4 book ai didi

vba - d = Worksheets(A(i)).Cells(B(j), l) + d 行出现错误 1004

转载 作者:行者123 更新时间:2023-12-04 20:16:47 25 4
gpt4 key购买 nike

我收到此命令的错误

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

最佳答案

这不起作用; And Operator 不能这样使用:

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

将其更改为:
If i > 10 Then
k = 54
p = 70
Else
k = 56
p = 66
End If

关于vba - d = Worksheets(A(i)).Cells(B(j), l) + d 行出现错误 1004,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22313901/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com