ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA: How to iterate through each cell of one specific row (https://www.excelbanter.com/excel-programming/292732-vba-how-iterate-through-each-cell-one-specific-row.html)

Hank[_3_]

VBA: How to iterate through each cell of one specific row
 
This seems like a simple task but I can't find anything in
the docs or Google.

How, using VBA, can I iterate through each used cell of a
specific row? For instance perform a test on each cell of
row 2?

I tried this, but it seems to select every cell of the
whole sheet:

For Each cell In ActiveSheet.UsedRange.Rows(2)


Thanks.

Chip Pearson

How to iterate through each cell of one specific row
 
Hank,

Try

Dim Cell As Range
For Each Cell In ActiveSheet.UsedRange.Rows(2).Cells


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Hank" wrote in message
...
This seems like a simple task but I can't find anything in
the docs or Google.

How, using VBA, can I iterate through each used cell of a
specific row? For instance perform a test on each cell of
row 2?

I tried this, but it seems to select every cell of the
whole sheet:

For Each cell In ActiveSheet.UsedRange.Rows(2)


Thanks.




Hank[_3_]

How to iterate through each cell of one specific row
 
That did the trick. Boy, do I feel silly!

Thanks from a newbie,
Hank


-----Original Message-----
Hank,

Try

Dim Cell As Range
For Each Cell In ActiveSheet.UsedRange.Rows(2).Cells


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Hank" wrote in

message
...
This seems like a simple task but I can't find anything

in
the docs or Google.

How, using VBA, can I iterate through each used cell of

a
specific row? For instance perform a test on each cell

of
row 2?

I tried this, but it seems to select every cell of the
whole sheet:

For Each cell In ActiveSheet.UsedRange.Rows(2)


Thanks.



.


Alan Beban[_4_]

VBA: How to iterate through each cell of one specific row
 
Not for me.

Alan Beban

Hank wrote:
This seems like a simple task but I can't find anything in
the docs or Google.

How, using VBA, can I iterate through each used cell of a
specific row? For instance perform a test on each cell of
row 2?

I tried this, but it seems to select every cell of the
whole sheet:

For Each cell In ActiveSheet.UsedRange.Rows(2)


Thanks.




All times are GMT +1. The time now is 10:02 AM.

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