PC Review


Reply
Thread Tools Rate Thread

Confused about sheets and "Select" vs "Activate"

 
 
Robert Crandal
Guest
Posts: n/a
 
      4th Jan 2010
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


 
Reply With Quote
 
 
 
 
Gary Keramidas
Guest
Posts: n/a
 
      4th Jan 2010
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" <(E-Mail Removed)> wrote in message
news:zuh0n.1684$%(E-Mail Removed)...
>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
>
>


 
Reply With Quote
 
Robert Crandal
Guest
Posts: n/a
 
      4th Jan 2010
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
news:%(E-Mail Removed)...
> 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 With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      4th Jan 2010
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
 
Reply With Quote
 
fisch4bill
Guest
Posts: n/a
 
      4th Jan 2010
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
> news:%(E-Mail Removed)...
> > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Field Names: "LongName", "ShortName", "Code", "Description","Comments" PeteCresswell Microsoft Access 2 25th Feb 2009 11:41 PM
"Select" and "Activate" failing? Ed Microsoft Excel Programming 3 13th Sep 2006 06:29 PM
<FORM METHOD="post" onSubmit="return fieldcheck()" name="orientation" action="http://ws-kitty.BU.edu/AT/survey/orientation/script/write.asp" language="JavaScript"> Joeyej Microsoft ASP .NET 0 4th Jun 2004 08:55 PM
Manual "Windows Update" produces "ActiveX/active scripting" error message even with "LOW" security level setting in "Trusted" Zone Ray2 Windows XP Help 1 14th Nov 2003 06:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:13 AM.