Hello,
I hobbled together a working macro through trial and error. I was wondering if someone could help me clean it up? I would like to learn how to do coding correctly and could use any advice you can give.
Sub tester()
Dim Newbook As Workbook
Dim i As Integer
Dim sName As String
Dim umName As String
Dim rvName As String
Dim tBox As Integer
line1:
tBox = Application.InputBox(prompt:="Enter Number of Tasks", Type:=1)
If tBox < 1 Then
MsgBox "Must be at least 1"
GoTo line1
Else
sName = ActiveSheet.Name
umName = (sName & " Original")
rvName = (sName & " Revised")
Set Newbook = Workbooks.Add
With Newbook
.Title = sName
.SaveAs Filename:=(sName & " .xls")
.Sheets.Add(, After:=Sheets(Worksheets.Count)).Name = umName
.Sheets.Add(, After:=Sheets(Worksheets.Count)).Name = rvName
For i = 1 To tBox
.Sheets.Add(, After:=Sheets(Worksheets.Count)).Name = ("Task " & i)
Next i
End With
End If
End Sub
And also, for this part:
.Sheets.Add(, After:=Sheets(Worksheets.Count)).Name = umName
I would like to copy the contents of the current worksheet to this newly created worksheet on the new workbook.
Can somone maybe help me work out how to do this?
Any help appreciated.
Bookmarks