+ Reply to Thread
Results 1 to 12 of 12

Procedure Too Large Error...

  1. #1
    Registered User
    Join Date
    04-08-2014
    Location
    Georgia
    MS-Off Ver
    Microsoft Office Professional Plus 2013
    Posts
    28

    Procedure Too Large Error...

    Hello,

    I am trying to use VBA to write a code to make it possible to link two cells together from different worksheets, but it needs to be linked both ways. When I input a number/date/word, I need it to update it in a particular cell on another worksheet and vice versa. For example, I need cells in column A (Transaction Number) in SHEET1 to be linked to cells in column D (Transaction Number) in SHEET2 [and vice versa]. I am not sure if you can link all cells in one column to all cells in another column, but I found a macro that I could copy the code and change the cell # to cover the cells needed. The problem I am running into, however, is that I can get the code to cover A2 all the way up to A120, but if I go any bigger then I get an error saying that the procedure is too large. I tried to make it shorter by using the same name twice (which I get the error "Ambiguous Name Detected." I know you cannot have the same name twice, but if I change it then the code does not work. For example, the name was: Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) and the name I changed the second one to was: Private Sub Workbook_SheetChange1(ByVal Sh As Object, ByVal Target As Range). I am not sure how to either change the name so that it will work, or shorten the macro. I am sure there is a more efficient way to write this code, but I am very new to this. Any help would be much appreciated!

    Attached is the excel workbook that I am using. To view the code, right-click SHEET1 and then click THIS WORKBOOK. The code I am using here is the one where I get the "Procedure Too Large" Error: [*Code courtesy of Dave Hawley from a different forum website that I found, where he posted it in response to someone's question]

    PO & SO TRACKING SHEET.xlsmPO & SO TRACKING SHEET.xlsm

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Procedure Too Large Error...

    Replace all your ThisWorkbook code with this:
    Please Login or Register  to view this content.
    Does that do what you expected?
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    04-08-2014
    Location
    Georgia
    MS-Off Ver
    Microsoft Office Professional Plus 2013
    Posts
    28

    Re: Procedure Too Large Error...

    Olly,

    Thank you so much! This works perfectly!!! Is it possible to use this code to link more cells in different columns. For example, link column B in SHEET1 to column E in SHEET2, column D in SHEET1 to column A in SHEET2, and column E in SHEET1 to column A in SHEET2 [plus some more combinations like these].

  4. #4
    Registered User
    Join Date
    04-08-2014
    Location
    Georgia
    MS-Off Ver
    Microsoft Office Professional Plus 2013
    Posts
    28

    Re: Procedure Too Large Error...

    Nevermind I figured it out! In case anyone comes across this looking to do something similar to what I am doing, below is how I was able to link more columns together using Olly's code:

    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub
    Application.EnableEvents = False
    If Sh.CodeName = "Sheet1" And Not Application.Intersect(Target, Range("A2:A10000")) Is Nothing Then
    Sheet2.Range("D" & Target.Row).Value = Target.Value
    ElseIf Sh.CodeName = "Sheet2" And Not Application.Intersect(Target, Range("D2:D10000")) Is Nothing Then
    Sheet1.Range("A" & Target.Row).Value = Target.Value
    End If
    Application.EnableEvents = True
    If Target.Cells.Count > 1 Then Exit Sub
    Application.EnableEvents = False
    If Sh.CodeName = "Sheet1" And Not Application.Intersect(Target, Range("B2:B10000")) Is Nothing Then
    Sheet2.Range("E" & Target.Row).Value = Target.Value
    ElseIf Sh.CodeName = "Sheet2" And Not Application.Intersect(Target, Range("E2:E10000")) Is Nothing Then
    Sheet1.Range("B" & Target.Row).Value = Target.Value
    End If
    Application.EnableEvents = True
    If Target.Cells.Count > 1 Then Exit Sub
    Application.EnableEvents = False
    If Sh.CodeName = "Sheet1" And Not Application.Intersect(Target, Range("D2:D10000")) Is Nothing Then
    Sheet2.Range("A" & Target.Row).Value = Target.Value
    ElseIf Sh.CodeName = "Sheet2" And Not Application.Intersect(Target, Range("A2:A10000")) Is Nothing Then
    Sheet1.Range("D" & Target.Row).Value = Target.Value
    End If
    Application.EnableEvents = True
    End Sub


    THANK YOU AGAIN OLLY!

  5. #5
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Procedure Too Large Error...

    Yes, easily:
    Please Login or Register  to view this content.
    See the commented lines, where you can repeat the 'elseif' for each combination of source and target sheets / ranges. Note that you aren't limited to A2:A120, you can specify the entire column, if you want...

    Make sense?

  6. #6
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Procedure Too Large Error...

    Woah - stop copying and pasting whole chunks of code!! See my post above, there's only two lines you need to repeat for each additional control combination!

    (Oh, and please use CODE tags when you post code)

  7. #7
    Registered User
    Join Date
    04-08-2014
    Location
    Georgia
    MS-Off Ver
    Microsoft Office Professional Plus 2013
    Posts
    28

    Re: Procedure Too Large Error...

    Yes it does I really appreciate your help with this! I've been trying to figure it out for days now..

  8. #8
    Registered User
    Join Date
    04-08-2014
    Location
    Georgia
    MS-Off Ver
    Microsoft Office Professional Plus 2013
    Posts
    28

    Re: Procedure Too Large Error...

    The original code you gave me was working great, but then I added more elseif to link more columns together and now I can't get it to work. I'm sure it's something I did to the code, but I haven't been able to fix it. Any suggestions?

  9. #9
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Procedure Too Large Error...

    Post your modified code (use CODE tags!) or attach your modified workbook.

    When you say 'can't get it to work' - does it cause an error, or not function as expected?

  10. #10
    Registered User
    Join Date
    04-08-2014
    Location
    Georgia
    MS-Off Ver
    Microsoft Office Professional Plus 2013
    Posts
    28

    Re: Procedure Too Large Error...

    I'm new to this so I hope I did the code tags correctly... It's not working in terms of not functioning as needed. The linked cells are not functioning as linked cells. I may have just messed up the code, but here is what I put into the THIS WORKBOOK in VBA:

    Please Login or Register  to view this content.

  11. #11
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Procedure Too Large Error...

    That all seems to work perfectly; for making changes in Sheet1 update cells in Sheet2. For the reciprocal changes, you need to code the reciprocal lines. For example:
    Please Login or Register  to view this content.
    That updates Sheet2-Column T with values from Sheet1-Column L. All good.
    Now, to update Sheet1-Column L with values from Sheet2-Column T, then you ALSO need to include the lines:
    Please Login or Register  to view this content.
    Note carefully the references to sheet names and column names

    One further note - unless 10000 is a magic number, you may find it equally convenient to just refer to the entire column: e.g.
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    04-08-2014
    Location
    Georgia
    MS-Off Ver
    Microsoft Office Professional Plus 2013
    Posts
    28

    Re: Procedure Too Large Error...

    It works now!!!!!! Thank you so much

+ 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. [SOLVED] Compile Error: Procedure too large
    By MileHigh_PhD in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-11-2018, 11:08 AM
  2. Compile Error: Procedure too Large
    By tarab in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-11-2013, 05:43 PM
  3. 'Compile Error - Procedure Too Large'
    By nods in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 11-11-2010, 12:44 AM
  4. Error Message (Compile Error, Procedure too Large)
    By dreicer_Jarr in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 10-29-2010, 03:52 AM
  5. Re: Compile error: Procedure too large
    By Susan Hayes in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-20-2005, 12:06 PM

Tags for this Thread

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