Code exceeded max size. Looking through this site it was mentioned to split up the code in multiple procedures. I tried this but it stops running after the first procedure is run. Below is reduced code for example. Thank you!
Sub Button31_Click()
Call Proc1
Call Proc2
Call Proc3
End Sub
Sub Proc1()
X = Workbooks("BDSubmittal.xlsm").Worksheets("database").Cells(3, 1).Value
Y = X + 3
For I = 4 To Y
If ActiveSheet.Cells(2, 3).Value = Workbooks("BDSubmittal.xlsm").Worksheets("database").Cells(I, 1).Value Then
RESPONSE = MsgBox("OVERWRITE EXISTING SUBMITTAL", vbYesNo)
If RESPONSE = vbYes Then
X = I
GoTo LINE1
Else
X = I + 1
GoTo LINE1
End If
Else: X = Y + 1
End If
Next I
LINE1:
Workbooks("BDSubmittal.xlsm").Worksheets("database").Cells(3, 5) = X
Workbooks("BDSubmittal.xlsm").Worksheets("database").Cells(X, 1).Value = ActiveSheet.Cells(2,
3).Value
Workbooks("BDSubmittal.xlsm").Worksheets("database").Cells(X, 2).Value = ActiveSheet.Cells(3,
3).Value
Workbooks("BDSubmittal.xlsm").Worksheets("database").Cells(X, 3).Value = ActiveSheet.Cells(4,
3).Value
End Sub
Sub Proc2()
Workbooks("BDSubmittal.xlsm").Worksheets("database").Cells(X, 105).Value = ActiveSheet.Cells(168,
3).Value
Workbooks("BDSubmittal.xlsm").Worksheets("database").Cells(X, 106).Value = ActiveSheet.Cells(168,
5).Value
Workbooks("BDSubmittal.xlsm").Worksheets("database").Cells(X, 107).Value = ActiveSheet.Cells(168,
7).Value
End Sub
Sub Proc3()
Workbooks("BDSubmittal.xlsm").Worksheets("database").Cells(X, 417).Value = ActiveSheet.Cells(640,
3).Value
Workbooks("BDSubmittal.xlsm").Worksheets("database").Cells(X, 418).Value = ActiveSheet.Cells(640,
5).Value '2
Workbooks("BDSubmittal.xlsm").Worksheets("database").Cells(X, 419).Value = ActiveSheet.Cells(640,
7).Value '3
End Sub
question from:
https://stackoverflow.com/questions/65943620/office-365-excel-receiving-error-code-1004-application-defined-or-object-defin 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…