+ Reply to Thread
Results 1 to 4 of 4

Finding LBound & UBound of 2D Arrays

Hybrid View

  1. #1
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Finding LBound & UBound of 2D Arrays

    Hi all,

    I just cannot seem to get my logic straight. How can I find the lower and upper bounds of a 2D array? I cannot just go with
    x = LBound(2DArray) To UBound(2DArray)
    Any ideas?

    Regards:
    Last edited by Mordred; 06-09-2011 at 11:22 AM.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,294

    Re: Finding LBound & UBound of 2D Arrays

    For x = LBound(2DArray, 1) To UBound(2DArray, 1)
       for y = LBound(2DArray, 2) To UBound(2DArray, 2)
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Finding LBound & UBound of 2D Arrays

    Thanks romperstomper for that, it hit the spot!

  4. #4
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Finding LBound & UBound of 2D Arrays

    Try:-
    Dim Ray
    Ray = Range("A1:F10").value
    MsgBox LBound(Ray, 1) 'First row
    MsgBox UBound(Ray, 1) 'Last Row
    MsgBox LBound(Ray, 2) 'First column
    MsgBox UBound(Ray, 2) 'Last column

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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