What is the correct syntax for telling VBA
"consider the value in sheet_1 in the cell that has offset (0,i) from the activecell"?
I tried with
Sheets("sheet_1").ActiveCell.Offset(0, i).Range("A1").Value
but it gives me
runtime error 438
Please note that my aim is to do:
If Sheets("sheet_1").ActiveCell.Offset(0, i).Range("A1").Value = Sheets("sheet_23").ActiveCell.Offset(0, i).Range("A1").Value Then
'do something
The ActiveCell
is only the single active cell in whichever sheet is active at the time the code is run. It cannot refer to a cell on an inactive sheet. Another sheet must be activated first.
Of course you can use the Address
property of an activecell and refer to the corresponding cell on an inactive sheet.
In general, it is recommended not to use activecell or selection .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.