Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default 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?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 695
Default 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?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 272
Default 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?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count Number of Rows Boying Opaw Excel Worksheet Functions 1 October 8th 09 04:46 AM
COUNT NUMBER OF ROWS Keep It Simple Stupid Excel Worksheet Functions 2 February 9th 07 06:54 PM
Count how many Rows ago a particular number was hit rhhince Excel Worksheet Functions 1 January 13th 07 09:06 PM
Count number of rows, where non relevant rows are hidden Pieter Excel Discussion (Misc queries) 2 November 8th 06 12:24 PM
Count rows and insert number to count them. Mex Excel Discussion (Misc queries) 6 August 23rd 06 02:29 AM


All times are GMT +1. The time now is 09:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"