I would like to add about 100 sheets to an Excel file, so first sheet would be WO #1, then WO #2......WO #100.
Is there any way to do this as a batch operation?
I created this macro which you can assign to a button:
The macro creates 100 blank sheets and i did this in a blank workbook which had the default Sheet1, 2 and 3, which i delete at the end of the code. You can put a quote in front of these lines and it will quit the deleting.Sub add_sheets() For i = 1 To 100 Worksheets.Add(after:=Worksheets(Worksheets.Count)).Name = "WO #" & i Next Worksheets("Sheet1").Delete Worksheets("Sheet2").Delete Worksheets("Sheet3").Delete End Sub
Cheers,
Arlette
If I helped, Don't forget to add to my reputation (click on the star below the post)
Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Use code tags when posting your VBA code: [code] Your code here [/code]
Im sorry im new at this. Where do I enter the code you provided, and how do I assign to a button?
Many thanks!
In the excel file, click Alt+F11. This will take you to the VBE Editor. On the left hand side, you will see Microsoft Excel Objects. Right click on it and say Insert-> Module. This will open a blank page on the right hand side. Copy the code there and save. Come back to the excel sheet and go to Developer tab, under Controls, there will be Insert. Select the button type. Insert it on your sheet. You can name it right away. Then right click and say Assign Macro. You will see the name of the macro that i created in the list. Select it. Save the file. You are ready to go.
Cheers,
Arlette
If I helped, Don't forget to add to my reputation (click on the star below the post)
Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Use code tags when posting your VBA code: [code] Your code here [/code]
Thanks! Now, if I want all these sheets to contain the same set of data, how would I do that? Basically, I want to copy whats in my first sheet and populate all 100 sheets with the same data.
Last edited by ilans1; 11-20-2011 at 03:13 PM.
The code is simple - Very similar to the 1st -
Sub add_sheets() For i = 1 To 100 Worksheets("Sheet1").Copy after:=Worksheets(Worksheets.Count) ActiveSheet.Name = "WO #" & i Next End Sub
Cheers,
Arlette
If I helped, Don't forget to add to my reputation (click on the star below the post)
Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Use code tags when posting your VBA code: [code] Your code here [/code]
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks