Confused about sheets and "Select" vs "Activate"
You have to make sure that the workbook is active first:
Workbooks("DataBook.xlsm").activate
Workbooks("DataBook.xlsm").Sheets(4).Select
I'd use this to save typing:
with Workbooks("DataBook.xlsm")
.activate
.Sheets(4).Select
end with
Same thing if you wanted to select a range on sheets(4).
Workbooks("DataBook.xlsm").activate
Workbooks("DataBook.xlsm").Sheets(4).Select
Workbooks("DataBook.xlsm").Sheets(4).range("x99"). select
with Workbooks("DataBook.xlsm")
.activate
with .Sheets(4)
.Select
.range("x99").select
end with
end with
Another way if you're going to a range:
Application.goto Workbooks("DataBook.xlsm").Sheets(4).range("x99"), _
scroll:=true 'or false
Robert Crandal wrote:
I am able to run the following code below:
Workbooks("DataBook.xlsm").Sheets(4).Activate
However, why does the following code give an error message:
Workbooks("DataBook.xlsm").Sheets(4).Select ' ERROR!!!
I thought a sheet "activate" call was the same thing as a sheet
"select" call. Can anybody explain what is going on here??
thank u
--
Dave Peterson
|