ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Count number of Rows with Value (https://www.excelbanter.com/excel-programming/376288-count-number-rows-value.html)

Student

Count number of Rows with Value
 
I would like to thank you up front

I am trying to count the number of rows used in an excel sheet

Dim ws as Worksheet
Set ws = Application.ActiveSheet
Dim LastRow as long

LastRow = ws.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row

This code finds any data found in the row from column A till the last
activated column. however I want the find method to find data in the row from
column A to X only.
How may I set the find method to search for data from column A to X for the
first 500 rows? Is that possible?


excelent

Count number of Rows with Value
 
i would do it my way :-)
MsgBox ("") & WorksheetFunction.CountA(Range("A1:X500"))


"Student" skrev:

I would like to thank you up front

I am trying to count the number of rows used in an excel sheet

Dim ws as Worksheet
Set ws = Application.ActiveSheet
Dim LastRow as long

LastRow = ws.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row

This code finds any data found in the row from column A till the last
activated column. however I want the find method to find data in the row from
column A to X only.
How may I set the find method to search for data from column A to X for the
first 500 rows? Is that possible?


Charles Chickering

Count number of Rows with Value
 
The answer to your question is to set the range that you are searching in the
first place:
ws.Range("A1:X500").Find(...)
--
Charles Chickering

"A good example is twice the value of good advice."


"Student" wrote:

I would like to thank you up front

I am trying to count the number of rows used in an excel sheet

Dim ws as Worksheet
Set ws = Application.ActiveSheet
Dim LastRow as long

LastRow = ws.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row

This code finds any data found in the row from column A till the last
activated column. however I want the find method to find data in the row from
column A to X only.
How may I set the find method to search for data from column A to X for the
first 500 rows? Is that possible?



All times are GMT +1. The time now is 03:06 AM.

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