ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   activate opened workbook via VBA (https://www.excelbanter.com/excel-discussion-misc-queries/86473-activate-opened-workbook-via-vba.html)

Noemi

activate opened workbook via VBA
 
Hi
We have entered the attached code into a workbook (Testing Stores.xls) but
when we run the code it does not perform the task below.

Windows("Store Response List " & stDate).Activate

which is meant to activate workbook Store Response List (date).xls so we can
update the file.

The stDate is the date which is provided from a cell found in workbook
(Testing Stores.xls).

For some reason when it comes to this code it jumps back to the begining and
does not activate the required workbook.

I beleive it has to do with the stDate which I dont know how to get araound.

Any help would be greatly appreciated.

Thanks
Noemi

Dave Peterson

activate opened workbook via VBA
 
What is stDate?

Is it declared as a String or a Date?

Maybe...

Windows("Store Response List " & format(stDate,"mm_dd_yyyy")&".xls").Activate
or
workbooks("Store Response List " & format(stDate,"mm_dd_yyyy")&".xls").Activate

would work.

I added the .xls extension, too.



Noemi wrote:

Hi
We have entered the attached code into a workbook (Testing Stores.xls) but
when we run the code it does not perform the task below.

Windows("Store Response List " & stDate).Activate

which is meant to activate workbook Store Response List (date).xls so we can
update the file.

The stDate is the date which is provided from a cell found in workbook
(Testing Stores.xls).

For some reason when it comes to this code it jumps back to the begining and
does not activate the required workbook.

I beleive it has to do with the stDate which I dont know how to get araound.

Any help would be greatly appreciated.

Thanks
Noemi


--

Dave Peterson


All times are GMT +1. The time now is 10:01 PM.

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