Life, SAP, Consulting, Programming, Coding, ASP.NET, Sharepoint, MVC, Javascript, PHP, WebDesign, CSS, HTML

This is VBA code for massively generating sheets in excel.

It copies the last sheets of the excel workbook and rename with the name you want.

It will popup for sheet prefix and ask for number of copies.

Run this script when documenting is convenient for me, in case you have a sheet template and want to apply for others.

Sub add_sheet()
Dim strSheetPrefixName As String
strSheetPrefixName = InputBox("Please Enter a Sheet Master name")
Dim nrCopy As Integer
nrCopy = InputBox("Please Enter a number of copies")
For i = 1 To nrCopy
Sheets(Worksheets.Count).Select
Sheets(Worksheets.Count).Copy After:=Sheets(Worksheets.Count)
Set WS = Sheets(Worksheets.Count)
If i < 10 Then
WS.Name = strSheetPrefixName & "_0" & i
Else
WS.Name = strSheetPrefixName & "_" & i
End If
Next i
End Sub

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: