+ Reply to Thread
Results 1 to 2 of 2

The "Next Cell" command in a "For Each ___ In ___" loop

Hybrid View

  1. #1
    Registered User
    Join Date
    08-21-2007
    Posts
    14

    The "Next Cell" command in a "For Each ___ In ___" loop

    Is there any way to make the "Next Cell" command go down instead of to the right?

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello favoritepsalm1,

    Excel stores the cells in a range first by column then by row. The For Each Loop follows the default storage method. You would need to use 2 loops if you want to examine all rows in the current column before going to the next column.
    Dim Rng  As Range
    
      Set Rng = Range("A1:D50")
    
        For C = 1 To 4
          For R = 1 to 50
            X = Cells(R, C).Value
          Next R
       Next C
    Sincerely,
    Leith Ross

+ 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