+ Reply to Thread
Results 1 to 3 of 3

Can't iterate thru a row with For

  1. #1
    peter
    Guest

    Can't iterate thru a row with For

    I'm trying to access the cells in a Row in the simplest manner, which I
    assume is a For Each loop, but it doesn't work. Have I done something
    wrong or is it VBA or Excel?
    Thanks,
    Peter.

    Dim rRow3 As Range, rCell As Range
    Set rRow3 = Rows(3)
    rRow3.Interior.ColorIndex = iPink ' row 3 = pink
    For Each rCell In rRow3
    rCell.Interior.ColorIndex = iClear
    ' clears whole row!
    If rCell.Value = "." Then ' type mismatch at runtime


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!

  2. #2
    Norman Jones
    Guest

    Re: Can't iterate thru a row with For

    Hi Peter,

    Try changing:

    > For Each rCell In rRow3


    to

    For Each rCell In rRow3.Cells


    ---
    Regards,
    Norman



    "peter" <[email protected]> wrote in message
    news:[email protected]...
    > I'm trying to access the cells in a Row in the simplest manner, which I
    > assume is a For Each loop, but it doesn't work. Have I done something
    > wrong or is it VBA or Excel?
    > Thanks,
    > Peter.
    >
    > Dim rRow3 As Range, rCell As Range
    > Set rRow3 = Rows(3)
    > rRow3.Interior.ColorIndex = iPink ' row 3 = pink
    > For Each rCell In rRow3
    > rCell.Interior.ColorIndex = iClear
    > ' clears whole row!
    > If rCell.Value = "." Then ' type mismatch at runtime
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!




  3. #3
    peter
    Guest

    Re: Can't iterate thru a row with For

    Thanks a lot Norman,
    Peter.



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!

+ 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