As I receive "PROCEDURE TOO LARGE" compile error I divided my code in multiple smaller subroutines, but I still receive this error and I don`t know how to divide it more. Here is the part of code that I didnt know how to divide more (as variable "I" doesnt update in main code as it should - it value is reset to 0 same as other variables included:
X7 = 109
Z7 = 0
For Q7 = 92 + Z6 To X6
If Cells(Q7, I + 4).Value = "" Then GoTo OPERATOR7I
If Cells(Q7, I + 4).Value >= TARGET - 0.01 Then GoTo OPERATOR7H
If Cells(Q7, I + 4).Value < TARGET - 0.01 Then
Cells(X7, I + 1).Value = Cells(Q7, I + 1).Value
Cells(X7, I + 4).Value = TARGET - Cells(Q7, I + 4).Value
Z7 = Z7 + 1
End If
If Cells(123, I + 5).Value < 60 + KK - 0.5 Then GoTo OPERATOR7F
If Cells(123, I + 5).Value > 60 + KK - 0.5 And Cells(123, I + 5).Value < 60 + KK + 0.5 Then GoTo OPERATOR7D
If Cells(123, I + 5).Value > 60 + KK + 0.5 Then GoTo OPERATOR7G
OPERATOR7G:
Cells(X7, I + 4).Value = Cells(X7, I + 4).Value - 1
If Cells(123, I + 5).Value > 60 + KK + 0.5 Then GoTo OPERATOR7G
If Cells(123, I + 5).Value > 60 + KK - 0.5 And Cells(123, I + 5).Value < 60 + KK + 0.5 Then GoTo OPERATOR7D
OPERATOR7I:
OPERATOR7F:
If Z7 = 0 Then GoTo LOOP0EDIT7
X7 = X7 + 1
LOOP0EDIT7:
OPERATOR7H:
Next Q7
If Application.Sum(Range(Cells(7, I + 15), Cells(Y1, I + 15))) < 0.01 Then GoTo LOOPRECALC7B
For XOXO7 = 7 To Y1
If Cells(XOXO7, I + 15).Value > 0.01 Then
Cells(X7, I + 1).Value = Cells(XOXO7, 3).Value
Cells(X7, I + 4).Value = Cells(XOXO7, I + 15).Value
X7 = X7 + 1
Z7 = Z7 + 1
End If
Next XOXO7
LOOPRECALC7C:
If Cells(123, I + 5).Value > 60 + KK + 0.5 Then GoTo LOOPRECALC7A
If Cells(123, I + 5).Value > 60 + KK - 0.5 And Cells(123, I + 5).Value < 60 + KK + 0.5 Then GoTo LOOPRECALC7B
If Cells(123, I + 5).Value < 60 + KK - 0.5 Then GoTo LOOPRECALC7B
LOOPRECALC7A:
Cells(X7, I + 4).Value = Cells(X7, I + 4).Value - 1
GoTo LOOPRECALC7C
LOOPRECALC7B:
OPERATOR7A:
If Cells(Y1 + 1, 3).Value = "" Then GoTo EXITLOOP7
If Cells(Y1 + 1, 4).Value = "Kontrola kvaliteta." Then GoTo QUALITYLOOP7A
Cells(X7, I + 1).Value = Cells(Y1 + 1, 3).Value
Cells(X7, I + 4).Value = TARGET
Y1 = Y1 + 1
GoTo QUALITYLOOP7B
QUALITYLOOP7A:
Y1 = Y1 + 1
GoTo OPERATOR7A
QUALITYLOOP7B:
OPERATOR7E:
If Cells(123, I + 5).Value < 60 + KK - 0.5 Then GoTo OPERATOR7B
If Cells(123, I + 5).Value > 60 + KK - 0.5 And Cells(123, I + 5).Value < 60 + KK + 0.5 Then GoTo OPERATOR7D
If Cells(123, I + 5).Value > 60 + KK + 0.5 Then GoTo OPERATOR7C
OPERATOR7B:
X7 = X7 + 1
GoTo OPERATOR7A
OPERATOR7C:
Cells(X7, I + 4).Value = Cells(X7, I + 4).Value - 1
GoTo OPERATOR7E
OPERATOR7D:
EXITLOOP7:
'OPERATOR8 LOOP
X8 = 126
Z8 = 0
For Q8 = 109 + Z7 To X7
If Cells(Q8, I + 4).Value = "" Then GoTo OPERATOR8I
If Cells(Q8, I + 4).Value >= TARGET - 0.01 Then GoTo OPERATOR8H
If Cells(Q8, I + 4).Value < TARGET - 0.01 Then
Cells(X8, I + 1).Value = Cells(Q8, I + 1).Value
Cells(X8, I + 4).Value = TARGET - Cells(Q8, I + 4).Value
Z8 = Z8 + 1
End If
If Cells(140, I + 5).Value < 60 + KK - 0.5 Then GoTo OPERATOR8F
If Cells(140, I + 5).Value > 60 + KK - 0.5 And Cells(140, I + 5).Value < 60 + KK + 0.5 Then GoTo OPERATOR8D
If Cells(140, I + 5).Value > 60 + KK + 0.5 Then GoTo OPERATOR8G
OPERATOR8G:
Cells(X8, I + 4).Value = Cells(X8, I + 4).Value - 1
If Cells(140, I + 5).Value > 60 + KK + 0.5 Then GoTo OPERATOR8G
If Cells(140, I + 5).Value > 60 + KK - 0.5 And Cells(140, I + 5).Value < 60 + KK + 0.5 Then GoTo OPERATOR8D
OPERATOR8I:
OPERATOR8F:
If Z8 = 0 Then GoTo LOOP0EDIT8
X8 = X8 + 1
LOOP0EDIT8:
OPERATOR8H:
Next Q8
If Application.Sum(Range(Cells(7, I + 15), Cells(Y1, I + 15))) < 0.01 Then GoTo LOOPRECALC8B
For XOXO8 = 7 To Y1
If Cells(XOXO8, I + 15).Value > 0.01 Then
Cells(X8, I + 1).Value = Cells(XOXO8, 3).Value
Cells(X8, I + 4).Value = Cells(XOXO8, I + 15).Value
X8 = X8 + 1
Z8 = Z8 + 1
End If
Next XOXO8
LOOPRECALC8C:
If Cells(140, I + 5).Value > 60 + KK + 0.5 Then GoTo LOOPRECALC8A
If Cells(140, I + 5).Value > 60 + KK - 0.5 And Cells(140, I + 5).Value < 60 + KK + 0.5 Then GoTo LOOPRECALC8B
If Cells(140, I + 5).Value < 60 + KK - 0.5 Then GoTo LOOPRECALC8B
LOOPRECALC8A:
Cells(X8, I + 4).Value = Cells(X8, I + 4).Value - 1
GoTo LOOPRECALC8C
LOOPRECALC8B:
OPERATOR8A:
If Cells(Y1 + 1, 3).Value = "" Then GoTo EXITLOOP8
If Cells(Y1 + 1, 4).Value = "Kontrola kvaliteta." Then GoTo QUALITYLOOP8A
Cells(X8, I + 1).Value = Cells(Y1 + 1, 3).Value
Cells(X8, I + 4).Value = TARGET
Y1 = Y1 + 1
GoTo QUALITYLOOP8B
QUALITYLOOP8A:
Y1 = Y1 + 1
GoTo OPERATOR8A
QUALITYLOOP8B:
OPERATOR8E:
If Cells(140, I + 5).Value < 60 + KK - 0.5 Then GoTo OPERATOR8B
If Cells(140, I + 5).Value > 60 + KK - 0.5 And Cells(140, I + 5).Value < 60 + KK + 0.5 Then GoTo OPERATOR8D
If Cells(140, I + 5).Value > 60 + KK + 0.5 Then GoTo OPERATOR8C
OPERATOR8B:
X8 = X8 + 1
GoTo OPERATOR8A
OPERATOR8C:
Cells(X8, I + 4).Value = Cells(X8, I + 4).Value - 1
GoTo OPERATOR8E
OPERATOR8D:
EXITLOOP8:
Code goes on and on with these LOOPS (X9, X10, X11....) and variables "KK" & "I" are also used in other parts of code for other functiones (some of them are divided into smaller subroutines)! How to shorten this?