+ Reply to Thread
Results 1 to 3 of 3

VBA: Procedure Too Large

  1. #1
    Forum Contributor
    Join Date
    08-20-2009
    Location
    new york
    MS-Off Ver
    Excel 2003
    Posts
    119

    VBA: Procedure Too Large

    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

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: VBA: Procedure Too Large

    Rather than submitting a flawed code or what you think the code should look like it is better to submit a description of what you are trying to do within a workbook and supplement that with an example workbook (with before and after representations).

    Case in point, there is absolutely nothing wrong with your code but since you didn't say what you are trying to do there is no way to know what you actually want it to do.

    Edit: Oh yeah, please use code tags around code.
    Last edited by stnkynts; 01-29-2016 at 12:13 AM.
    If you are happy with my response please click the * in the lower left of my post.

  3. #3
    Forum Contributor
    Join Date
    08-20-2009
    Location
    new york
    MS-Off Ver
    Excel 2003
    Posts
    119

    Re: VBA: Procedure Too Large

    Quote Originally Posted by stnkynts View Post
    Rather than submitting a flawed code or what you think the code should look like it is better to submit a description of what you are trying to do within a workbook and supplement that with an example workbook (with before and after representations).

    Case in point, there is absolutely nothing wrong with your code but since you didn't say what you are trying to do there is no way to know what you actually want it to do.

    Edit: Oh yeah, please use code tags around code.
    Actually, I have an idea now. I am thinking to create an array for "John, Mike, Jenny, ....", then use a look for the array.

    I will try to use array tomorrow and see if it works.

    Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. procedure too large
    By mrjackg in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-02-2014, 07:42 PM
  2. Procedure too large
    By yikwei in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-31-2014, 07:49 AM
  3. Procedure too Large
    By Spherous in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-07-2013, 06:42 AM
  4. [SOLVED] Procedure too large
    By battenborrow in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-02-2013, 08:51 AM
  5. Procedure too large
    By JonathonHardy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-27-2011, 01:34 PM
  6. Procedure Too Large
    By shsassy in forum Excel General
    Replies: 2
    Last Post: 12-14-2007, 01:20 PM
  7. Procedure too Large !!!
    By Herve_Rob in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-13-2007, 12:56 PM

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