ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Compile Error: Proceedure too large (https://www.excelbanter.com/excel-programming/395093-compile-error-proceedure-too-large.html)

IT_roofer

Compile Error: Proceedure too large
 
I have a routine that calculates % Done of a 9-step userform-based program
and when I got done writing the code for it, I received this error. The code
routine is 2054 lines of code so posting code here wouldn't be a good idea.
But, the basic idea is that the code checks whether or not a checkbox has
been checked and if it has it check the next in line. If it's not, it will
skip it and check the next in line, etc. I'm terrible with loops of any kind,
so maybe someone could help me shorten up the routine?

Here's the first 100 (or so) lines:

Sub formupdater()
Dim i As String
i = 30
If start_here.step1.Value = True Then
If start_here.step2.Value = True Then
If start_here.step3.Value = True Then
If start_here.step4.Value = True Then
If start_here.step5.Value = True Then
If start_here.step6.Value = True Then
If start_here.step7.Value = True Then
If start_here.step8.Value = True Then
If start_here.step9.Value = True Then
start_here.statfront.Width = i * 9
start_here.StatusBar1.Panels(3).Text =
"Status: " & Int(((i * 9) / 270) * 100) & "% Complete"
Else
start_here.statfront.Width = i * 8
start_here.StatusBar1.Panels(3).Text =
"Status: " & Int(((i * 8) / 270) * 100) & "% Complete"
End If
ElseIf start_here.step9.Value = True Then
start_here.statfront.Width = i * 8
start_here.StatusBar1.Panels(3).Text =
"Status: " & Int(((i * 8) / 270) * 100) & "% Complete"
Else
start_here.statfront.Width = i * 7
start_here.StatusBar1.Panels(3).Text =
"Status: " & Int(((i * 7) / 270) * 100) & "% Complete"
End If
ElseIf start_here.step8.Value = True Then
If start_here.step9.Value = True Then
start_here.statfront.Width = i * 8
start_here.StatusBar1.Panels(3).Text =
"Status: " & Int(((i * 8) / 270) * 100) & "% Complete"
Else
start_here.statfront.Width = i * 7
start_here.StatusBar1.Panels(3).Text =
"Status: " & Int(((i * 7) / 270) * 100) & "% Complete"
End If
ElseIf start_here.step9.Value = True Then
start_here.statfront.Width = i * 7
start_here.StatusBar1.Panels(3).Text = "Status:
" & Int(((i * 7) / 270) * 100) & "% Complete"
Else
start_here.statfront.Width = i * 6
start_here.StatusBar1.Panels(3).Text = "Status:
" & Int(((i * 6) / 270) * 100) & "% Complete"
End If
ElseIf start_here.step7.Value = True Then
If start_here.step8.Value = True Then
If start_here.step9.Value = True Then
start_here.statfront.Width = i * 8
start_here.StatusBar1.Panels(3).Text =
"Status: " & Int(((i * 8) / 270) * 100) & "% Complete"
Else
start_here.statfront.Width = i * 7
start_here.StatusBar1.Panels(3).Text =
"Status: " & Int(((i * 7) / 270) * 100) & "% Complete"
End If
ElseIf start_here.step9.Value = True Then
start_here.statfront.Width = i * 7
start_here.StatusBar1.Panels(3).Text = "Status:
" & Int(((i * 7) / 270) * 100) & "% Complete"
Else
start_here.statfront.Width = i * 6
start_here.StatusBar1.Panels(3).Text = "Status:
" & Int(((i * 6) / 270) * 100) & "% Complete"
End If
ElseIf start_here.step8.Value = True Then
If start_here.step9.Value = True Then
start_here.statfront.Width = i * 7
start_here.StatusBar1.Panels(3).Text = "Status:
" & Int(((i * 7) / 270) * 100) & "% Complete"
Else
start_here.statfront.Width = i * 6
start_here.StatusBar1.Panels(3).Text = "Status:
" & Int(((i * 6) / 270) * 100) & "% Complete"
End If
ElseIf start_here.step9.Value = True Then
start_here.statfront.Width = i * 6
start_here.StatusBar1.Panels(3).Text = "Status: " &
Int(((i * 6) / 270) * 100) & "% Complete"
Else
start_here.statfront.Width = i * 5
start_here.StatusBar1.Panels(3).Text = "Status: " &
Int(((i * 5) / 270) * 100) & "% Complete"
End If
ElseIf start_here.step6.Value = True Then
If start_here.step7.Value = True Then
If start_here.step8.Value = True Then
If start_here.step9.Value = True Then
start_here.statfront.Width = i * 8
start_here.StatusBar1.Panels(3).Text =
"Status: " & Int(((i * 8) / 270) * 100) & "% Complete"
Else
start_here.statfront.Width = i * 7
start_here.StatusBar1.Panels(3).Text =
"Status: " & Int(((i * 7) / 270) * 100) & "% Complete"
End If
ElseIf start_here.step9.Value = True Then
start_here.statfront.Width = i * 7
start_here.StatusBar1.Panels(3).Text = "Status:
" & Int(((i * 7) / 270) * 100) & "% Complete"
Else
start_here.statfront.Width = i * 6
start_here.StatusBar1.Panels(3).Text = "Status:
" & Int(((i * 6) / 270) * 100) & "% Complete"
End If
ElseIf start_here.step8.Value = True Then
If start_here.step9.Value = True Then
start_here.statfront.Width = i * 7
start_here.StatusBar1.Panels(3).Text = "Status:
" & Int(((i * 7) / 270) * 100) & "% Complete"
Else
start_here.statfront.Width = i * 6
start_here.StatusBar1.Panels(3).Text = "Status:
" & Int(((i * 6) / 270) * 100) & "% Complete"
End If




All times are GMT +1. The time now is 05:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com