I am currently trying to program a macro.
- I am writing the macro in a new black workbook (this is part of the requirement) and I have a lot of data in a different workbook.
- I need to use the macro to read the data in that different workbook and spit out errors encountered for each column and write it in the blank workbook (that i am programming macro in).
- So for each column it’s suppose to have list of row numbers an error was encountered (and nothing else). I’m trying to write an If statement to do this and i keep getting an error message stating “expected then or go to”.
This is what I have so far:
If [Dataset1.xls]Data1!R2C1=53 AND [Dataset1.xls]Data1!R2C1=453 AND [Dataset1.xls]Data1!R2C1=953 Then
The dataset1.xls is the workbook that holds all the data and Data1 is the sheet in that workbook with all the data. I might be accessing the separate workbook totally wrong. Can you guys please help. Thank you very much in advance.
This is most of the code:
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
You should change
Instead of:
Regards
— full code: