ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can't iterate thru a row with For (https://www.excelbanter.com/excel-programming/320268-cant-iterate-thru-row.html)

peter

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!

Norman Jones

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" wrote in message
...
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!




peter

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!


All times are GMT +1. The time now is 03:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com