+ Reply to Thread
Results 1 to 4 of 4

Using "For Each" with ListRows in a ListObject

Hybrid View

brucemc777 Using "For Each" with... 05-04-2016, 12:36 PM
cytop Re: Using "For Each" with... 05-04-2016, 12:58 PM
cytop Re: Using "For Each" with... 05-04-2016, 12:59 PM
brucemc777 Re: Using "For Each" with... 05-04-2016, 01:53 PM
  1. #1
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    615

    Using "For Each" with ListRows in a ListObject

    I am attempting to learn how better to use a For/Next loop with a collection, but it is rough...

    Can someone show me what I am doing wrong here -

    loTblHistory is set to a specific table and I have verified the validity of the reference and it's existence.

    I have tried to Dim obListRow as a ListRow and as an Object in separate runs, then run it as:

                    
                    For Each obListRow In loTblHistory
                        
                    Next obListRow
    but errors out each time with Run-time error 438, Object doesn't support this property or method, which you probably already know!

    Is there a proper way to code this in this manner, and if so, what am I missing?

    Thank-you!!!

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Using "For Each" with ListRows in a ListObject

    Ignore - mouse bounce

  3. #3
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Using "For Each" with ListRows in a ListObject

    You have to identify what you want to iterate.

    Typed freehand. Replace ListObjects(1) with the name of yours...
    Sub x()
    
       Dim oLI As ListRow
       
       For Each oLI In ListObjects(1).ListRows
          Debug.Print oLI.Range.Address
       Next
       
    End Sub

  4. #4
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    615

    Re: Using "For Each" with ListRows in a ListObject

    I knew I was going to embarrass myself...

    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. Can you refer to ListObject Rows by "name"?
    By shawnvw in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-18-2015, 06:42 PM
  2. Selection.ListObject.ListRows(1).Delete inquiry
    By swade730 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-25-2014, 11:18 AM
  3. ListObject.ListRows not returning last row of table if header row
    By excel_joe in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-21-2014, 04:59 PM
  4. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  5. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  6. "method add of object listrows failed"
    By McGinley in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-08-2012, 09:07 AM
  7. Replies: 7
    Last Post: 05-13-2006, 05:02 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