ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Count Property (https://www.excelbanter.com/excel-programming/294255-count-property.html)

Jacqui

Count Property
 
I have included the following For Next statement in my
code, using the Count Property. The purpose is to
determine the first visible row in an auto filtered list.
There's more VBA within the Sub but when I step through at
For i = 1 to cells(Rows.Count, 1).End (xlUp), VBA exits
from my code. Is it because I have not applied the Count
property to a Range Object. If so, how do I rewrite? Can
anyone kindly help?

Many thanks
Jacqui


For i = 1 To Cells(Rows.Count, 1).End(xlUp)
If Rows(i).EntireRow.Hidden = False Then
iStartRow = i
Exit For
End If
Next


Rob van Gelder[_4_]

Count Property
 
Looks like you want to put .Row at the end

For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"jacqui" wrote in message
...
I have included the following For Next statement in my
code, using the Count Property. The purpose is to
determine the first visible row in an auto filtered list.
There's more VBA within the Sub but when I step through at
For i = 1 to cells(Rows.Count, 1).End (xlUp), VBA exits
from my code. Is it because I have not applied the Count
property to a Range Object. If so, how do I rewrite? Can
anyone kindly help?

Many thanks
Jacqui


For i = 1 To Cells(Rows.Count, 1).End(xlUp)
If Rows(i).EntireRow.Hidden = False Then
iStartRow = i
Exit For
End If
Next




Bob Phillips[_6_]

Count Property
 
Jacqui,

The problenm is that you have a range object, and you need a long/.integer.

Try

For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row
If Rows(i).EntireRow.Hidden = False Then
iStartRow = i
Exit For
End If
Next


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"jacqui" wrote in message
...
I have included the following For Next statement in my
code, using the Count Property. The purpose is to
determine the first visible row in an auto filtered list.
There's more VBA within the Sub but when I step through at
For i = 1 to cells(Rows.Count, 1).End (xlUp), VBA exits
from my code. Is it because I have not applied the Count
property to a Range Object. If so, how do I rewrite? Can
anyone kindly help?

Many thanks
Jacqui


For i = 1 To Cells(Rows.Count, 1).End(xlUp)
If Rows(i).EntireRow.Hidden = False Then
iStartRow = i
Exit For
End If
Next





All times are GMT +1. The time now is 01:37 AM.

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