VBA Check for New Workbook

ebrehm

Board Regular
Joined
Dec 5, 2008
Messages
51
I need help Please!!!

I currently have code that runs through several actions for each variable "Num" - 1 - 20. My current Coding states something like,
If Num = 1 then Add new workbook and continue to add only "Sheets" for Num = 2 - 20. HOWEVER>.... It has come to my attention that not all of the users start with NUM = 1. Some users skip the first line (Num = 1) and start with Num = 2 or 3, etc.

So my problem now is, if a user skips num = 1 and starts with num = 2, the code will never Add a New "Workbook". Therefore, if no New Workbook is ever added no New Sheets can be added to the workbook.

How can I code so that a New Workbook is added on the first line item whether it be num = 1 or 2 or 3, 4,... etc through 20. Some kind of a check for the first line item????

By the way - I have a variable name for the new workbook that num = 1 is supposed to create: "newsheetname". But how do I check the status of that variable if it hasn't been created yet???

Thanks - Erica :p
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

ebrehm

Board Regular
Joined
Dec 5, 2008
Messages
51
Duh...
I guess it just took me putting it all out on "paper" to figure out that I can do a "IsEmpty" check for the variable first then proceed to insert new Workbook if needed.

Thanks :)
 

Watch MrExcel Video

Forum statistics

Threads
1,133,381
Messages
5,658,485
Members
418,447
Latest member
AdamAl

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
Top