我希望在处理工作表"现场团队"中的范围时分配一个范围的值。作为变量集。但是获取对象对象/应用程序定义错误 我是VBA的新手(以及一般的编码),请帮助我!
Private Sub CommandButton1_Click()
Dim Arr2(1 To 51, 1 To 1) As Variant
Dim i As Integer
For i = 1 To 51
Arr2(i, 1) = Worksheets("Sheet1").Cells(1 + i, C)
Next i
For i = 1 To 51
If Arr2(i, 1) Then Worksheets("Field Team").Cells(i + 78, C).Interior.ColorIndex = 37
Next i
End Sub
答案 0 :(得分:1)
小错误,请尝试如下:
Private Sub CommandButton1_Click()
Dim Arr2(1 To 51, 1 To 1) As Variant
Dim i As Integer
For i = 1 To 51
Arr2(i, 1) = Worksheets("Sheet1").Cells(1 + i, 3)
Next i
For i = 1 To 51
If Arr2(i, 1) Then
Worksheets("Field Team").Cells(i + 78, 3).Interior.ColorIndex = 37
End If
Next i
End Sub