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
 

Some videos you may like

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

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 :)
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,363
Messages
5,510,862
Members
408,814
Latest member
lgorczyca

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top