Activating newly created workbook

craigyg

Board Regular
Joined
Dec 14, 2005
Messages
114
How can I create a new workbook and then activate that new workbook? I can't figure out how I can refer to that newly created workbook. Anyone know what I am missing? Thanks,

Craig
 

Some videos you may like

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
When you add a wb, it is automatically the active one:

<font face=Tahoma><SPAN style="color:#00007F">Sub</SPAN> Foo()
    Workbooks.Add
    With ActiveWorkbook
        MsgBox "This is the new one"
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

So you can refer to it with ActiveWorkbook.

HTH,

Smitty
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,912
Office Version
  1. 365
Platform
  1. Windows
Craig

Why do you need/want to activate the new workbook?

This code will activate a newly created workbook.
Code:
Dim wbNew
    
    Set wbNew = Workbooks.Add
    
    wbNew.Activate
 

Watch MrExcel Video

Forum statistics

Threads
1,113,793
Messages
5,544,315
Members
410,602
Latest member
lidovi
Top