Asking How Many Workbooks to Create

999HelpPlease

New Member
Joined
Jul 16, 2014
Messages
35
I need to create a VBA that asks how many workbooks we want to create and then save them numbering them 1.xlsx to however many we end up with.

I have started the macro but I only know how to write it using this and it only gives me 10. I need it to ask how many we are going to create.

Sub 2()
Dim i As Double
For i = 1 To 10
Workbooks.Add
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "" & i & ".xlsx"
ActiveWorkbook.Close
Next
End Sub

I also have it this way


Dim ProceedStatus As String
ProceedStatus = InputBox("Do you want to create a new workbook ? Yes / No")
Do While LCase(ProceedStatus) = "yes"
Workbooks.Add
ProceedStatus = InputBox("Do you want to create a new workbook ? Yes / No")
Loop
End Sub

They both do a part but neither really work.

Can someone help me out?
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Using the other code, it may be saving them but you may not be seeing it as it happens so fast. Try setting an exact file path to follow so you can trace if it saves. It may be saving in a location you're not familiar with.
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,021
Members
452,374
Latest member
keccles

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