ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   worksheet.activate not activating (https://www.excelbanter.com/excel-programming/334313-worksheet-activate-not-activating.html)

[email protected]

worksheet.activate not activating
 
as a last command to several routines in a program, I have a line with
worksheets("....").activate; however, the worksheet does not get
activated upon termination of the program. Any ideas how to get this
to happen?

Thanks.

Smokii


Ronald Dodge

worksheet.activate not activating
 
I never had a such problem myself with this sort of issue. However, as a
general rule of thumb, I avoid using the "Activate" method unless it's
really needed, which should really be the exception rather than the norm. I
know the macro recorder uses the Activate method, but it's limited to what
it can do, and most times, it's only really there to learn how macros are
created and ran, which is how I got started working with macros in Excel.
However, along the way early on, I ran into several issues (this was when I
was using Excel 97, SR2) using the Select and Activate methods (Select on
ranges and Activate on worksheets). This also was the same type of reasons
why I don't use ActiveWorksheet or ActiveWorkbook so much either. Much of
the programming that I did real early on, it involved several worksheets and
something like 20 to 25 different workbooks, though not all at one time, but
still, enough to where it caused some issues, and not only that, but I also
wanted to be able to use the computer for other things while the program was
running, which meant I had to eliminate the ActiveWorkbook, ActiveWorksheet,
Activate Method, and Select Method all together from my program, as well as
any SendKeys statements/functions. As far as that's concerned, there is one
such program that I have to use the SendKeys statements for, which by the
way, I only trust the Application's SendKeys, not VBA's SendKeys, as there's
an issue with the VBA one.

Are you using "Applicaiton.ScreenUpdating"? if you are setting this to
False for efficiency purposes, reset this to "True" at the end of the code,
as this has to be done else you won't get what you need.

--
Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000

wrote in message
oups.com...
as a last command to several routines in a program, I have a line with
worksheets("....").activate; however, the worksheet does not get
activated upon termination of the program. Any ideas how to get this
to happen?

Thanks.

Smokii




[email protected]

worksheet.activate not activating
 
I appreciate your experience and comments. I am in fact unable to use
my computer effectively while my program is running.

I am opening up approximately 50 or so files one at a time, processing
data on from these files, adding charts and performing various
algorithms, and then saving the file as an xls. I use the
activeworkbook and activeworksheet throughout the code (errr).

anyhow, to answer your question, at the end of my program, I do change
screenupdating back to true before I apply worksheet.activate. What is
happening is that once my program begins, various worksheets in the
program become active, and upon termination, i want to user to start
off where he began. if there is another way, i'd be obliged to know
it.

Thanks.

Smokii


Dave Peterson

worksheet.activate not activating
 
I use a range variable or two...

'at the start
dim CurSel as range
dim ActCell as range

set cursel = selection
set actcell = activecell

'do all your stuff

application.goto cursel
actcell.activate



wrote:

I appreciate your experience and comments. I am in fact unable to use
my computer effectively while my program is running.

I am opening up approximately 50 or so files one at a time, processing
data on from these files, adding charts and performing various
algorithms, and then saving the file as an xls. I use the
activeworkbook and activeworksheet throughout the code (errr).

anyhow, to answer your question, at the end of my program, I do change
screenupdating back to true before I apply worksheet.activate. What is
happening is that once my program begins, various worksheets in the
program become active, and upon termination, i want to user to start
off where he began. if there is another way, i'd be obliged to know
it.

Thanks.

Smokii


--

Dave Peterson

Dave Peterson

worksheet.activate not activating
 
Are you sure the correct workbook was active when you tried to activate that
worksheet?

(If you're unlucky, then maybe there was a worksheet name that matched and you
just got the wrong one activated???)

wrote:

I appreciate your experience and comments. I am in fact unable to use
my computer effectively while my program is running.

I am opening up approximately 50 or so files one at a time, processing
data on from these files, adding charts and performing various
algorithms, and then saving the file as an xls. I use the
activeworkbook and activeworksheet throughout the code (errr).

anyhow, to answer your question, at the end of my program, I do change
screenupdating back to true before I apply worksheet.activate. What is
happening is that once my program begins, various worksheets in the
program become active, and upon termination, i want to user to start
off where he began. if there is another way, i'd be obliged to know
it.

Thanks.

Smokii


--

Dave Peterson

[email protected]

worksheet.activate not activating
 
i'm sure...i have a single file where i run my program...and it has a
specific sheet name. it worked a few iterations ago, but it suddenly
stopped.



All times are GMT +1. The time now is 08:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com