SlinkRN
Well-known Member
- Joined
- Oct 29, 2002
- Messages
- 724
Hi there, I know I'm probably just doing something stupid, but my cancel button doesn't do a thing to stop my input box. It's a long compicated macro so please be patient but I thought I'd better include the whole macro so you can find out what I'm doing wrong. Can anyone help?
Sub AddNewEmployee()
Dim strName As String
Dim strName2 As String
Call GoToRNSchedule
Call ChooseRange
Application.ScreenUpdating = False
Call UnprotectAllSheets
Selection.EntireRow.Insert 'insert new row in RN sheet
On Error GoTo canceled
strName = InputBox("Enter employee name: Last name, First name.", "Employee Name")
ActiveCell = strName 'enter new name in RN sheet
ActiveCell.AddComment 'add comment so that addcomment sub will work later
ActiveCell.Comment.Visible = False
ActiveCell.Comment.Text Text:="" 'comment is blank for now
ActiveCell.Select
frmShift.Show 'allow for shift choice so will show up with correct shifts
ActiveWindow.ScrollWorkbookTabs Sheets:=20
Sheets.Add.Name = strName 'add new schedule sheet for employee
ActiveSheet.Move After:=Sheets(30)
Sheets(strName).Select
Range("A6").Select
Sheets("RN").Select
ActiveCell.Offset(0, 1).Resize(1, 31).Copy 'copy cells so can be linked to sched sheet
Sheets(strName).Select
ActiveSheet.Paste Link:=True
Range("I6:O6").Select
Selection.Cut Destination:=Range("A15:G15")
Range("Q6:W6").Select
Selection.Cut Destination:=Range("a24:g24")
Range("Y6:ae6").Select
Selection.Cut Destination:=Range("a33:g33")
Sheets("RN").Select
Range("C12:I12").Copy 'copy days of week
Sheets(strName).Select
Range("a4:g4").Select
ActiveSheet.Paste Link:=True
Range("a13:g13").Select
ActiveSheet.Paste Link:=True
Range("a22:g22").Select
ActiveSheet.Paste Link:=True
Range("a31:g31").Select
ActiveSheet.Paste Link:=True
Columns("a:g").ColumnWidth = 10
Columns("a:g").HorizontalAlignment = xlCenter
Range("c2").Select 'enter employee name to sched sheet
ActiveCell.Value = strName
Call GoToRNSchedule
ActiveCell.Offset(1, 0).Select
strName2 = ActiveCell.Value
Sheets(strName2).Select
ActiveSheet.Shapes("Button 2").Select 'copy command buttons for sched sheet
Selection.Copy
Sheets(strName).Select
ActiveSheet.Paste
Selection.ShapeRange.IncrementLeft 120.75
Selection.ShapeRange.IncrementTop -12.75
Range("A1").Select
Sheets(strName2).Select
ActiveSheet.Shapes("Button 1").Select
Selection.Copy
Sheets(strName).Select
ActiveSheet.Paste
Selection.ShapeRange.IncrementLeft -48.75
Sheets(strName2).Select
Range("I13:J34").Copy 'copy legend for sched sheet
Sheets(strName).Select
Range("I13:J34").PasteSpecial
Columns("I:I").EntireColumn.AutoFit
Columns("J:J").EntireColumn.AutoFit
ActiveWindow.DisplayZeros = False
Sheets("RN").Select
Range("c13:AG13").Copy 'copy dates for sched sheet
Sheets(strName).Select
Range("A5:AE5").Select
ActiveSheet.Paste Link:=True
Range("I5:O5").Select
Selection.Cut Destination:=Range("A14:G14")
Range("Q5:W5").Select
Selection.Cut Destination:=Range("A23:G23")
Range("Y5:AE5").Select
Selection.Cut Destination:=Range("A32:G32")
Range("B1").Select
Sheets("RN").Select
Call Sheet1.colormeblue
Call Sheet1.colormewhite
Call Sheet1.uncolormeblue
Call LinkSchedSheets
Call SortSheetsAlphabetically
Call ProtectAllSheets
Call gotomainpage
canceled:
Application.ScreenUpdating = True
End Sub
Is there just TOO MUCH stuff between "go to canceled" and "canceled"?
Thanks for your help, Slink
Sub AddNewEmployee()
Dim strName As String
Dim strName2 As String
Call GoToRNSchedule
Call ChooseRange
Application.ScreenUpdating = False
Call UnprotectAllSheets
Selection.EntireRow.Insert 'insert new row in RN sheet
On Error GoTo canceled
strName = InputBox("Enter employee name: Last name, First name.", "Employee Name")
ActiveCell = strName 'enter new name in RN sheet
ActiveCell.AddComment 'add comment so that addcomment sub will work later
ActiveCell.Comment.Visible = False
ActiveCell.Comment.Text Text:="" 'comment is blank for now
ActiveCell.Select
frmShift.Show 'allow for shift choice so will show up with correct shifts
ActiveWindow.ScrollWorkbookTabs Sheets:=20
Sheets.Add.Name = strName 'add new schedule sheet for employee
ActiveSheet.Move After:=Sheets(30)
Sheets(strName).Select
Range("A6").Select
Sheets("RN").Select
ActiveCell.Offset(0, 1).Resize(1, 31).Copy 'copy cells so can be linked to sched sheet
Sheets(strName).Select
ActiveSheet.Paste Link:=True
Range("I6:O6").Select
Selection.Cut Destination:=Range("A15:G15")
Range("Q6:W6").Select
Selection.Cut Destination:=Range("a24:g24")
Range("Y6:ae6").Select
Selection.Cut Destination:=Range("a33:g33")
Sheets("RN").Select
Range("C12:I12").Copy 'copy days of week
Sheets(strName).Select
Range("a4:g4").Select
ActiveSheet.Paste Link:=True
Range("a13:g13").Select
ActiveSheet.Paste Link:=True
Range("a22:g22").Select
ActiveSheet.Paste Link:=True
Range("a31:g31").Select
ActiveSheet.Paste Link:=True
Columns("a:g").ColumnWidth = 10
Columns("a:g").HorizontalAlignment = xlCenter
Range("c2").Select 'enter employee name to sched sheet
ActiveCell.Value = strName
Call GoToRNSchedule
ActiveCell.Offset(1, 0).Select
strName2 = ActiveCell.Value
Sheets(strName2).Select
ActiveSheet.Shapes("Button 2").Select 'copy command buttons for sched sheet
Selection.Copy
Sheets(strName).Select
ActiveSheet.Paste
Selection.ShapeRange.IncrementLeft 120.75
Selection.ShapeRange.IncrementTop -12.75
Range("A1").Select
Sheets(strName2).Select
ActiveSheet.Shapes("Button 1").Select
Selection.Copy
Sheets(strName).Select
ActiveSheet.Paste
Selection.ShapeRange.IncrementLeft -48.75
Sheets(strName2).Select
Range("I13:J34").Copy 'copy legend for sched sheet
Sheets(strName).Select
Range("I13:J34").PasteSpecial
Columns("I:I").EntireColumn.AutoFit
Columns("J:J").EntireColumn.AutoFit
ActiveWindow.DisplayZeros = False
Sheets("RN").Select
Range("c13:AG13").Copy 'copy dates for sched sheet
Sheets(strName).Select
Range("A5:AE5").Select
ActiveSheet.Paste Link:=True
Range("I5:O5").Select
Selection.Cut Destination:=Range("A14:G14")
Range("Q5:W5").Select
Selection.Cut Destination:=Range("A23:G23")
Range("Y5:AE5").Select
Selection.Cut Destination:=Range("A32:G32")
Range("B1").Select
Sheets("RN").Select
Call Sheet1.colormeblue
Call Sheet1.colormewhite
Call Sheet1.uncolormeblue
Call LinkSchedSheets
Call SortSheetsAlphabetically
Call ProtectAllSheets
Call gotomainpage
canceled:
Application.ScreenUpdating = True
End Sub
Is there just TOO MUCH stuff between "go to canceled" and "canceled"?
Thanks for your help, Slink