Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default activating a workbook

I need to activate a workbook through a cell reference. the workook
name is stored in cell A1 as "pnlreport_060321.xls". This name
automatically changes daily based on the date. This is how I wrote the
code to activate the workbook:

Sub import()

Dim fileA As String
fileA = Range("A1").Value
windows("fileA").Activate

End Sub

Please HELP. How would I activate a workbook which is already open. I
cannot use the file name in the code because the name changes every
day.

Thanks : )

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default activating a workbook

if it's already open, just delete the quotes

Windows(fileA).Activate


--


Gary


"VB Script for Excel" wrote in message
oups.com...
I need to activate a workbook through a cell reference. the workook
name is stored in cell A1 as "pnlreport_060321.xls". This name
automatically changes daily based on the date. This is how I wrote the
code to activate the workbook:

Sub import()

Dim fileA As String
fileA = Range("A1").Value
windows("fileA").Activate

End Sub

Please HELP. How would I activate a workbook which is already open. I
cannot use the file name in the code because the name changes every
day.

Thanks : )



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default activating a workbook

Gary
It still does not work. Gives me a Run-Time Error 9 message: Subscript
out of range.
Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default activating a workbook

what, exactly, is in A1

--


Gary


"VB Script for Excel" wrote in message
oups.com...
I need to activate a workbook through a cell reference. the workook
name is stored in cell A1 as "pnlreport_060321.xls". This name
automatically changes daily based on the date. This is how I wrote the
code to activate the workbook:

Sub import()

Dim fileA As String
fileA = Range("A1").Value
windows("fileA").Activate

End Sub

Please HELP. How would I activate a workbook which is already open. I
cannot use the file name in the code because the name changes every
day.

Thanks : )



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default activating a workbook

also, is the workbook already open, or do you need code to open it, too?

--


Gary


"VB Script for Excel" wrote in message
ups.com...
Gary
It still does not work. Gives me a Run-Time Error 9 message: Subscript
out of range.
Thanks





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default activating a workbook

if it's already loaded, try this. you may not have the file extension in A1

Windows(fileA & ".xls").Activate


--


Gary


"VB Script for Excel" wrote in message
ups.com...
Gary
It still does not work. Gives me a Run-Time Error 9 message: Subscript
out of range.
Thanks



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default activating a workbook

The workbook is already open. Need to activate that open workbook.
filename to open that workbook is located in cell A1 of current
workbook (the workbook in which I am writing the macros).
:)

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default activating a workbook

A1 in the current workbook gives me the file name that changes everyday
due to date.
A1 shows:
="pnlreport_"& TEXT(now(),"yymmdd")& ".xls"
this will produce: pnlreport_060321.xls if today's date is 21st March
2006.

I need to activate this file, which is already open through VB. But it
gives me a run time error in above code.


Thanks

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default activating a workbook

Again gives me same Run Time Error '9': Subscript out of range. Makes
the line Windows(fileA & ".xls").Activate as yellow.

Thnx

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default activating a workbook

i put your formula in A1 and this worked for me
Windows(fileA).Activate

maybe you should qualify the range with the sheet name, since i don't know what
the active sheet is

fileA =
workbooks("YourWorkbookName").worksheets("YourShee tName").Range("A1").Value

--


Gary


"VB Script for Excel" wrote in message
oups.com...
A1 in the current workbook gives me the file name that changes everyday
due to date.
A1 shows:
="pnlreport_"& TEXT(now(),"yymmdd")& ".xls"
this will produce: pnlreport_060321.xls if today's date is 21st March
2006.

I need to activate this file, which is already open through VB. But it
gives me a run time error in above code.


Thanks





  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default activating a workbook

you have & ".xls" already in A1, i didn't know until you just posted the
formula, so this wouldn't work.

--


Gary


"VB Script for Excel" wrote in message
ups.com...
Again gives me same Run Time Error '9': Subscript out of range. Makes
the line Windows(fileA & ".xls").Activate as yellow.

Thnx



  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default activating a workbook

IT WORKS GARY!!!!
thank you so much and thanks a millionsss.
i really appreciate your help

Dhaval

  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default activating a workbook

you're welcome

--


Gary


"VB Script for Excel" wrote in message
oups.com...
IT WORKS GARY!!!!
thank you so much and thanks a millionsss.
i really appreciate your help

Dhaval



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
Working within a workbook without activating it? hyyfte[_11_] Excel Programming 3 June 4th 06 08:00 PM
Working within a workbook without activating it? hyyfte[_9_] Excel Programming 1 September 20th 04 03:34 PM
Open workbook without activating it Kelley[_2_] Excel Programming 3 October 29th 03 04:49 PM
Activating workbook with variable Name Mark Klaus Excel Programming 2 October 24th 03 10:41 PM
Activating a workbook help bmwmcrider Excel Programming 1 October 21st 03 01:48 PM


All times are GMT +1. The time now is 09:41 AM.

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

About Us

"It's about Microsoft Excel"