Results 1 to 25 of 25

'Compile Error - Procedure Too Large'

Threaded View

  1. #1
    Registered User
    Join Date
    10-06-2010
    Location
    Dunstable,England
    MS-Off Ver
    Excel 2010
    Posts
    95

    'Compile Error - Procedure Too Large'

    I have a rota input form that has 30 lines of input enabling the user to add 30 members of staff at a time. The form is designed with the staff names down the left and start and finish time drop downs for each day of the week acrross the right. The staff name is only entered once for each week even the work all 7 days.

    I wrote the below code which works fine for one line of the rota form, but when I replicate it 30 times I get a 'Compile Error - Procedure Too Large'.

    Is there a way of breaking the code up or using a loop to replicate the code?

    The following input fields increase in value by 1 for each line.

    TeamMbr1
    DayStart1
    DayFinish1

    The following inout fields are static because they are only selected once at the top of the form.

    WeekDD2.
    SiteDD2
    DeptDD2

    The full code is attached
    ..
    Private Sub RunBtn_Click()
    
    If WeekDD2.Value = "Select Week" Or SiteDD2.Value = "Select Site" Or DeptDD2.Value = "Team/Dept" Then
    
      MsgBox "Please Select a Site,Week and Department", vbExclamation, "Error"
    
    Exit Sub
    
    End If
    
    If TeamMbr1.Value = "Team Mbr" Or FriStart1.Value = "Start" Or FriFinish1.Value = "Finish" Then
    GoTo Saturday01
    Exit Sub
    
    End If
    
    Sheets("Rota Input").Cells(Rows.Count, "H").End(xlUp).Offset(1, 0) = Me.WeekDD2.Value
    
    Sheets("Rota").Range("G2").Value = Me.WeekDD2.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "I").End(xlUp).Offset(1, 0) = "Friday"
       
    Sheets("Rota Input").Cells(Rows.Count, "J").End(xlUp).Offset(1, 0) = Me.SiteDD2.Value
    
    Sheets("Rota").Range("C2").Value = Me.SiteDD2.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "K").End(xlUp).Offset(1, 0) = Me.DeptDD2.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "L").End(xlUp).Offset(1, 0) = Me.TeamMbr1.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "M").End(xlUp).Offset(1, 0) = Me.FriStart1.Text
    
    Sheets("Rota Input").Cells(Rows.Count, "N").End(xlUp).Offset(1, 0) = Me.FriFinish1.Value
    
    
    
    Saturday01:
    
    If TeamMbr1.Value = "Team Mbr" Or SatStart1.Value = "Start" Or SatFinish1.Value = "Finish" Then
    GoTo Sunday01
    
    Exit Sub
    
    End If
    
    Sheets("Rota Input").Cells(Rows.Count, "H").End(xlUp).Offset(1, 0) = Me.WeekDD2.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "I").End(xlUp).Offset(1, 0) = "Saturday"
       
    Sheets("Rota Input").Cells(Rows.Count, "J").End(xlUp).Offset(1, 0) = Me.SiteDD2.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "K").End(xlUp).Offset(1, 0) = Me.DeptDD2.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "L").End(xlUp).Offset(1, 0) = Me.TeamMbr1.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "M").End(xlUp).Offset(1, 0) = Me.SatStart1.Text
    
    Sheets("Rota Input").Cells(Rows.Count, "N").End(xlUp).Offset(1, 0) = Me.SatFinish1.Value
    
    
    
    Sunday01:
    
    If TeamMbr1.Value = "Team Mbr" Or SunStart1.Value = "Start" Or SunFinish1.Value = "Finish" Then
    GoTo Monday01
    
    Exit Sub
    
    End If
    
    
    Sheets("Rota Input").Cells(Rows.Count, "H").End(xlUp).Offset(1, 0) = Me.WeekDD2.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "I").End(xlUp).Offset(1, 0) = "Sunday"
       
    Sheets("Rota Input").Cells(Rows.Count, "J").End(xlUp).Offset(1, 0) = Me.SiteDD2.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "K").End(xlUp).Offset(1, 0) = Me.DeptDD2.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "L").End(xlUp).Offset(1, 0) = Me.TeamMbr1.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "M").End(xlUp).Offset(1, 0) = Me.SunStart1.Text
    
    Sheets("Rota Input").Cells(Rows.Count, "N").End(xlUp).Offset(1, 0) = Me.SunFinish1.Value
    
    
    
    Monday01:
    
    If TeamMbr1.Value = "Team Mbr" Or MonStart1.Value = "Start" Or MonFinish1.Value = "Finish" Then
    GoTo Tuesday01
    
    Exit Sub
    
    End If
    
    
    
    Sheets("Rota Input").Cells(Rows.Count, "H").End(xlUp).Offset(1, 0) = Me.WeekDD2.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "I").End(xlUp).Offset(1, 0) = "Monday"
       
    Sheets("Rota Input").Cells(Rows.Count, "J").End(xlUp).Offset(1, 0) = Me.SiteDD2.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "K").End(xlUp).Offset(1, 0) = Me.DeptDD2.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "L").End(xlUp).Offset(1, 0) = Me.TeamMbr1.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "M").End(xlUp).Offset(1, 0) = Me.MonStart1.Text
    
    Sheets("Rota Input").Cells(Rows.Count, "N").End(xlUp).Offset(1, 0) = Me.MonFinish1.Value
    
    
    Tuesday01:
    
    If TeamMbr1.Value = "Team Mbr" Or TuesStart1.Value = "Start" Or TuesFinish1.Value = "Finish" Then
    GoTo Wednesday01
    
    Exit Sub
    
    End If
    
    
    Sheets("Rota Input").Cells(Rows.Count, "H").End(xlUp).Offset(1, 0) = Me.WeekDD2.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "I").End(xlUp).Offset(1, 0) = "Tuesday"
       
    Sheets("Rota Input").Cells(Rows.Count, "J").End(xlUp).Offset(1, 0) = Me.SiteDD2.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "K").End(xlUp).Offset(1, 0) = Me.DeptDD2.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "L").End(xlUp).Offset(1, 0) = Me.TeamMbr1.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "M").End(xlUp).Offset(1, 0) = Me.TuesStart1.Text
    
    Sheets("Rota Input").Cells(Rows.Count, "N").End(xlUp).Offset(1, 0) = Me.TuesFinish1.Value
    
    
    
    Wednesday01:
    
    If TeamMbr1.Value = "Team Mbr" Or WedStart1.Value = "Start" Or WedFinish1.Value = "Finish" Then
    GoTo Thursday01
    
    Exit Sub
    
    End If
    
    
    
    Sheets("Rota Input").Cells(Rows.Count, "H").End(xlUp).Offset(1, 0) = Me.WeekDD2.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "I").End(xlUp).Offset(1, 0) = "Wednesday"
       
    Sheets("Rota Input").Cells(Rows.Count, "J").End(xlUp).Offset(1, 0) = Me.SiteDD2.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "K").End(xlUp).Offset(1, 0) = Me.DeptDD2.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "L").End(xlUp).Offset(1, 0) = Me.TeamMbr1.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "M").End(xlUp).Offset(1, 0) = Me.WedStart1.Text
    
    Sheets("Rota Input").Cells(Rows.Count, "N").End(xlUp).Offset(1, 0) = Me.WedFinish1.Value
    
    
    
    Thursday01:
    
    If TeamMbr1.Value = "Team Mbr" Or ThursStart1.Value = "Start" Or ThursFinish1.Value = "Finish" Then
    GoTo Friday02
    
    Exit Sub
    
    End If
    
    
    
    Sheets("Rota Input").Cells(Rows.Count, "H").End(xlUp).Offset(1, 0) = Me.WeekDD2.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "I").End(xlUp).Offset(1, 0) = "Thursday"
       
    Sheets("Rota Input").Cells(Rows.Count, "J").End(xlUp).Offset(1, 0) = Me.SiteDD2.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "K").End(xlUp).Offset(1, 0) = Me.DeptDD2.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "L").End(xlUp).Offset(1, 0) = Me.TeamMbr1.Value
    
    Sheets("Rota Input").Cells(Rows.Count, "M").End(xlUp).Offset(1, 0) = Me.ThursStart1.Text
    
    Sheets("Rota Input").Cells(Rows.Count, "N").End(xlUp).Offset(1, 0) = Me.ThursFinish1.Value
    Attached Files Attached Files
    Last edited by nods; 11-11-2010 at 12:45 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1