PDA

View Full Version : Create multiple workbooks



kellyhell
04-03-2012, 01:41 AM
Not sure how to do this after looking at various options but here is the scenario.

I have a master workbook that has multiple sheets. Each month I want to create a set of workbooks based on this master with different names based on the month and Team name.

The new workbook's names will be based on the master then the month then the team name.

For example the master is called MUL. The new sheets will be called
MUL SMP02 (this is the month) Team 1 (this is the name of the team)

The rest of the workbooks will be MUL SMP02 Team 2, MUL SMP02 Team 3 etc.

The next month would be SMP03 etc etc. Preferably a user form would display to ask the user which month (e.g. SMP02) and the number of Teams and these would be used in the workbook name.

The new workbooks would then be saved to a specific folder.

I have a bit of VBA knowledge but not enough to create this code.

Any help would be greatly appreaciated.

TIA

chandansify
04-03-2012, 01:59 AM
I assume with basic VBA knowledge you can create a simple form with some controls to input values.

From that user form, pass the values to the below method to create sheet.

e.g. use below method to pass the values


CreateMySheets "MUL", 5, 4
'In this case, sheets would come as "MUL SMP05 Team 1" etc.


Sub CreateMySheets(sMaster As String, iMonth As Integer, iTeams As Integer)

Dim ctr As Integer
Dim shtMySheet As Worksheet
For ctr = 1 To iTeams
Set shtMySheet = Worksheets.Add(Type:=XlSheetType.xlWorksheet)
shtMySheet.Name = sMaster & " SMP" & Format(iMonth, "00") & " Team " & ctr
Next
End Sub

kellyhell
04-03-2012, 02:22 AM
I am still a little stuck with this. When I say I have a bit VBA knowledge I mean very little to be honest. Any further help would be appreciated