My code has error message "Procedure Too Large", actually, the procedure is within a For loop.
However, let me make a simple example without loop.
These four lines repeats over and over again, how can I write another Sub() for these four lines? If I don't bring "John", "Mike", "Jenny" into another Sub(), then it cannot figure out Str2.
I cannot make a loop for "John, Mike, Jenny", I need to add more and more in the future.
Maybe my code should look like this:
Str = "John"
Call Something
Str = "Mike"
Call Something
Str = "Jenny"
Call Something
Anyway, how can I fix the code to avoid the error message.
--------------------------------------------
Sub Giant()
Dim i As Integer
Dim Str, Str2 As String
Dim LastRow As Integer
Str = "John"
Str2 = "Hello, " & Str & "!"
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
ActiveSheet.Cells(LastRow + 1, 1).Value = Str2
Str = "Mike"
Str2 = "Hello, " & Str & "!"
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
ActiveSheet.Cells(LastRow + 1, 1).Value = Str2
Str = "Jenny"
Str2 = "Hello, " & Str & "!"
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
ActiveSheet.Cells(LastRow + 1, 1).Value = Str2
End Sub
Bookmarks