Activate "current workbook"

  • Thread starter Thread starter Darin Kramer
  • Start date Start date
D

Darin Kramer

Currently within my VB I have

Windows("FileA.xls").Activate

This is no good as the file name will change depending upon which book I
have open, but I want the macro to run on the active book (I will
specify sheet which is the same in all books)

I want to activate current Book.

(there will only be one file active, Macro is running from Personal
Book, which it goes into to copy and paste some data across to File A)

Any ideas?

Thanks

D
 
Set a workbook object = to the current workbook something like this

dim wbkCurrent as workbook

set wbkCurrent = activeworkbook

You now have a refence that workbook that you can access at any time even if
you activate other workbooks subsequent to this declaration.
 
The activeworkbook does not need to be activated. It is already active.

in any event, you could use

Activeworkbook.Activate
 
Hi Bob,

The problem is the sheet name is not always file a, it could be
anything, I just want excel to go to the previous sheet.

ie There will be 3 workbooks visible, :
1) Personal Macro workbook
2) Workbook called XYZ (always visible)
3) Workbook called File A (or File B or file C etc...)

What I am trying to do is copy sheet called Summary from Workbook called
XYZ into item 3 listed above (ie into the workbook NOT called xyz and
NOt Personal)

THis may well be impossible...

Thanks

D
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top