ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   count rows in a column for looping (https://www.excelbanter.com/excel-discussion-misc-queries/138274-count-rows-column-looping.html)

damorrison

count rows in a column for looping
 
I was using this code

RwsCnt = ActiveSheet.UsedRange.Rows.Count
for i = 1 to RwsCnt

'Code

Next i

it works correctly but the value of the row count increases as the
macro goes along

how can I get this to count just the rows in column B?


Gary''s Student

count rows in a column for looping
 
For i = 1 To Cells(Rows.Count, 2).End(xlUp).Row
--
Gary''s Student - gsnu200714


"damorrison" wrote:

I was using this code

RwsCnt = ActiveSheet.UsedRange.Rows.Count
for i = 1 to RwsCnt

'Code

Next i

it works correctly but the value of the row count increases as the
macro goes along

how can I get this to count just the rows in column B?



damorrison

count rows in a column for looping
 
On Apr 8, 2:48 pm, Gary''s Student
wrote:
For i = 1 To Cells(Rows.Count, 2).End(xlUp).Row
--
Gary''s Student - gsnu200714

"damorrison" wrote:
I was using this code


RwsCnt = ActiveSheet.UsedRange.Rows.Count
for i = 1 to RwsCnt


'Code


Next i


it works correctly but the value of the row count increases as the
macro goes along


how can I get this to count just the rows in column B?


Great ,
thanks



All times are GMT +1. The time now is 07:04 PM.

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