Consulting

Results 1 to 4 of 4

Thread: VBA code (macros) understanding

  1. #1

    VBA code (macros) understanding

    Hello,

    Whenever I want to run macros I get the following Debug error:

    For i = 1 To UBound(units)
    table(lRow, units(i, 2)) = Range(units(i, 1))

    Can someone explain what it means?

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Welcome to the forum!

    There is really no way to know without knowing what your variable values are. You can use Debug.Print to put run results in VBE Immediate window.

  3. #3
    What error precisely? And what has been assigned to units?
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    I'm guessing that "units" is a 2 dimensional array based on Range(units(I,1))


    For i = 1 To UBound(units) table(lRow, units(i, 2)) = Range(units(i, 1))

    If that's true, then you need something like

    For i = 1 To UBound(units, 1)
    in the For loop (need to explicitly specify the dimension for multi-dimensional array)
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •