Reputation: 31
I have found a error that I don't understand. In (A) statements, I have a error code 1004 - "the Select method of the Range Class failed". (B) statement is Ok. No error. Why can't I use Range("J5").Select with Worksheet object in the second time? I have a few statements between Select worksheet 1 and Select worksheet 2, but I don't believe they interfer.
Set wbDF = Workbooks.Add
wbDF.Worksheets(1).Range("H4").Select
wbDF.Worksheets(2).Range("J5").Select '(A)
wbDF.Worksheets(2).Activate '(B)
Range("J5").Select
Upvotes: 0
Views: 47
Reputation: 19727
You have to Activate or Select the sheet for you to select a Range in that sheet.
So your example (A) doesn't work since Worksheet(2) is not the currently selected Sheet.
Refer to this post on how to avoid using Select.
Upvotes: 1