Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Sub CopysheetMultipleTimes()
- Dim NoOfCopies As Variant
- Dim pCounter As Integer
- Dim tWB As Workbook
- Dim sh As Worksheet
- xlSettings False ' turn off xl settings
- Set tWB = ThisWorkbook ' we are using thisworkbook
- Set sh = tWB.ActiveSheet ' we want to copy activesheet
- ' let user request number of copies
- NoOfCopies = Application.InputBox("How many copies do you what?", "Rochem Inspectors", , , , , 1)
- If NoOfCopies <> False Then ' test if x on inputbox has been pressed
- pCounter = 0
- Do ' create the desired number of sheets
- sh.Copy After:=tWB.Sheets(sh.Name)
- pCounter = pCounter + 1
- Loop Until pCounter = NoOfCopies
- Else
- ' x was pressed, give user feedback
- MsgBox "Copy Was Cancelled", , "Rochem Inspectors"
- End If
- xlSettings True ' restore xl settings
- End Sub
- Sub xlSettings(t As Boolean) ' sets alerts and udating to desired setting
- With Application
- .ScreenUpdating = t
- .DisplayAlerts = t
- End With
- End Sub
Add Comment
Please, Sign In to add comment