Is there code in VB to move from one workbook to another?

danno_mbk

Board Regular
Joined
Sep 6, 2004
Messages
102
Hello everyone,

Quick question (i have serched old posts but found nothing) so now I am asking the question..

Is it possible in VB to move from one workbook to another without selecting the workbook name ?

A bit like using Ctrl + Page up/down to move between worksheets, but move between workbooks instead

example:
workbook 1 name = "Main"
workbook 2 name = 2Data 01/01/07"

the reason I am asking is that the second workbook will be a different name each month. So the code will not work each month if the code filename is specfic as the files names will be different ?

thanks in advance

Danno :)
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Hi,

If your macro opens the workbook, once the workbook is Active use

Set NewWorkbook as activesheet

Then to select it later

Newworkbook.activate
 
Upvote 0
You don't have to name them -you can refer to them in the order that they were opened

Workbooks(1)
Workbooks(2)
Workbooks(3)

etc.
 
Upvote 0
cool ok I will try the workbook 1 workbook2 option see if that does what I need it to do.

thanks

and yes in answer to Steve059L question there will only be 2 workbooks one called main the other could be anything..

cheers
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,626
Members
449,094
Latest member
bsb1122

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top