我目前正在尝试编程宏。
这是我到目前为止所做的:
If [Dataset1.xls]Data1!R2C1=53 AND [Dataset1.xls]Data1!R2C1=453 AND [Dataset1.xls]Data1!R2C1=953 Then
dataset1.xls是保存所有数据的工作簿,Data1是该工作簿中包含所有数据的工作表。我可能会完全错误地访问单独的工作簿。你能帮忙吗?非常感谢你提前。
这是大部分代码:
Dim numrow As Long
Dim count As Long
count = 2
With Workbooks("Dataset1.xls").Sheets("Data1")
numrow = .Range("A1", .Range("A1").End(xlDown)).Rows.count
End With
Do Until count = numrow
If [Dataset1.xls]Data1!R2C1<>53 AND [Dataset1.xls]Data1!R2C1<>453 AND [Dataset1.xls]Data1!R2C1<>953 Then
End If
count = count + 1
Loop
答案 0 :(得分:0)
你应该改变
If Workbooks("Dataset1.xls").Sheets("Data1").Cells(2, 1).Value <> 53 AND Workbooks("Dataset1.xls").Sheets("Data1").Cells(2, 1).Value <> 453 AND Workbooks("Dataset1.xls").Sheets("Data1").Cells(2, 1).Value <> 953 Then
而不是:
If [Dataset1.xls]Data1!R2C1<>53 AND [Dataset1.xls]Data1!R2C1<>453 AND [Dataset1.xls]Data1!R2C1<>953 Then
此致
- 完整代码:
range = Workbooks("Dataset1.xls").Worksheets("Data").Range("A65536").End(xlUp).Row
For i = 2 To range
If Workbooks("Dataset1.xls").Sheets("Data1").Cells(i, 1).Value <> 53 AND Workbooks("Dataset1.xls").Sheets("Data1").Cells(i, 1).Value <> 453 AND Workbooks("Dataset1.xls").Sheets("Data1").Cells(i, 1).Value <> 953 Then
End IF
Next i