View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Hari Prasadh Hari Prasadh is offline
external usenet poster
 
Posts: 63
Default Select a sheet and activate a Window

Hi Bob,

I have been able to *reproduce* the problem. I have the code below which
fails.

ThisWorkbook.Worksheets("basesheet").select

When I change it to

ThisWorkbook.Worksheets("basesheet").Activate

Its fine.

Now some background... Suppose during code execution I'm on basesheet (part
of ThisWorkbook) and due to some Loop I navigate to some other WORKBOOK and
when I want to come back to the basesheet within ThisworkBook I use the --
..Select code -- and it fails, but if I use the activate code it doesnt fail.

What I can see from above is that (pls correct me if am wrong) if I try to
activate a worksheet within some workbook which was active the last time the
workbook was worked upon then probably select method fails. Is that right?

Thanks a lot,
Hari
India


"Hari Prasadh" wrote in message
...
Hi Bob,

I tried that previously and got a error. When i changed it to -- select --
it worked. So, I thought that may be sheets can only be selected.
I tried with -- Activate -- now and its working perfectly fine. (Dunno why
I had the problem in the first place.)

You can activate a sheet as well.

Anyway, then whats the difference between select and activate? Especially
when I record a macro and click on some other workbook I get --
Windows("hari").activate -- and if I click on some other Worksheet I
get -- Sheets("sheet1").select. So, what causes VB to assign activate and
select in a selective manner.

Thanks a lot,
Hari
India

"Bob Phillips" wrote in message
...
Hari,

You can activate a sheet as well.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Hari Prasadh" wrote in message
...
Hi,

Why do we Select a sheet but Activate a window.

(Above from the syntax writing point of view)

Thanks a lot,
Hari
India