Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default Confused about sheets and "Select" vs "Activate"

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Confused about sheets and "Select" vs "Activate"

i'm guessing you're trying to select a sheet in a non-active workbook. do you
have more than 1 workbook open?

--


Gary Keramidas
Excel 2003


"Robert Crandal" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default Confused about sheets and "Select" vs "Activate"

Yes, that is correct. I have several workbooks open.

I thought that Workbooks("DataBook.xlsm") would specify
the correct workbook and therefore that either
Sheets(n).Activate OR Sheets(n).Select would do the same
thing????

"Gary Keramidas" <GKeramidasAtMSN.com wrote in message
...
i'm guessing you're trying to select a sheet in a non-active workbook. do
you have more than 1 workbook open?

--


Gary Keramidas
Excel 2003


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Confused about sheets and "Select" vs "Activate"

I tried to duplicate your situation by having two workbooks open and issuing
each of the statements you've listed. If the workbook that I tried to
"SELECT" the sheet in was not the active workbook, I got the error. As long
as I was selecting the sheet in the active workbook, however, there was no
problem. I could, however "ACTIVATE" any sheet regardless of which workbook
is active.

I think the the "SELECT" option only looks to the active workbook even when
you specify a workbook, whereas the "ACTIVATE" command seems to be able to
use anything within the Excel application. I get a similar response when
trying to "ACTIVATE" or "SELECT" a cell that's not in the active sheet.

Anyway, this is what I came up with, maybe some of the MVP folks here know
more about it, and may have to correct me if I'm mistaken.

HTH
Bill

"Robert Crandal" wrote:

Yes, that is correct. I have several workbooks open.

I thought that Workbooks("DataBook.xlsm") would specify
the correct workbook and therefore that either
Sheets(n).Activate OR Sheets(n).Select would do the same
thing????

"Gary Keramidas" <GKeramidasAtMSN.com wrote in message
...
i'm guessing you're trying to select a sheet in a non-active workbook. do
you have more than 1 workbook open?

--


Gary Keramidas
Excel 2003


.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
"Select" and "Activate" failing? Ed Excel Programming 3 September 13th 06 06:29 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
Using "Cells" to write "Range("A:A,H:H").Select" Trip Ives[_2_] Excel Programming 3 June 5th 04 03:13 PM


All times are GMT +1. The time now is 05:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"