Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default count rows with data

Need to count the number of rows that contain data - ignoring formats.
--
Regards,

Bryan Brassell
Padgett Business Services
281-897-9141
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 296
Default count rows with data

On Fri, 31 Mar 2006 14:30:02 -0800, Bryan Brassell
wrote:

Need to count the number of rows that contain data - ignoring formats.


How are you defining data? Is that any piece of information, i.e.
text, formula or number.

Does just one occurence of a piece of data in a row mean that you
count the row, or does every row have to contain data in every cell in
a range of columns before you count the row?

Rgds

__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default count rows with data

any data, formulas, numbers, text, etc. One occurence in the row does count.
--
Regards,

Bryan Brassell
Padgett Business Services
281-897-9141


"Richard Buttrey" wrote:

On Fri, 31 Mar 2006 14:30:02 -0800, Bryan Brassell
wrote:

Need to count the number of rows that contain data - ignoring formats.


How are you defining data? Is that any piece of information, i.e.
text, formula or number.

Does just one occurence of a piece of data in a row mean that you
count the row, or does every row have to contain data in every cell in
a range of columns before you count the row?

Rgds

__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default count rows with data

Bryan,

Try this code:

Sub RowCount()

Dim Ans As String
Dim R As Long
Dim C As Range
Dim Rng As Range

On Error GoTo EndMacro

If Selection.Rows.Count 1 Then
Set Rng = Selection
Else
Set Rng = ActiveSheet.UsedRange.Rows
End If
For R = Rng.Rows.Count To 1 Step -1
If Application.WorksheetFunction.CountA(Rng.Rows(R).E ntireRow) 0 Then
Exit For
End If
Next R

Ans = MsgBox(R & " rows in worksheet.", vbOKOnly)

EndMacro:

End Sub
--
Ken Hudson


"Bryan Brassell" wrote:

Need to count the number of rows that contain data - ignoring formats.
--
Regards,

Bryan Brassell
Padgett Business Services
281-897-9141

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default count rows with data

If I mis-understodd your question and you don't want to count empty rows
interspersed throughout the worksheet, try the code below. (Credit to Chip
Pearson from whom I got the basic logic.)

Sub RowCount()

Dim Ans As String
Dim R As Long
Dim C As Range
Dim Rng As Range
Dim DataRows As Double

On Error GoTo EndMacro

DataRows = 0
If Selection.Rows.Count 1 Then
Set Rng = Selection
Else
Set Rng = ActiveSheet.UsedRange.Rows
End If
For R = Rng.Rows.Count To 1 Step -1
If Application.WorksheetFunction.CountA(Rng.Rows(R).E ntireRow) 0 Then
DataRows = DataRows + 1
End If
Next R

Ans = MsgBox(DataRows & " rows in worksheet.", vbOKOnly)

EndMacro:

End Sub
--
Ken Hudson


"Bryan Brassell" wrote:

Need to count the number of rows that contain data - ignoring formats.
--
Regards,

Bryan Brassell
Padgett Business Services
281-897-9141

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 filled data rows until empty Dallman Ross Excel Discussion (Misc queries) 7 May 9th 23 11:43 AM
How to count rows with changing data Steve in MN Excel Worksheet Functions 1 November 15th 09 03:27 PM
Count all rows in column with data, Except rows 1-5 Gregory Day Excel Worksheet Functions 4 March 27th 08 02:58 PM
Count rows and insert number to count them. Mex Excel Discussion (Misc queries) 6 August 23rd 06 02:29 AM
count only the visible rows in a data table Eric[_27_] Excel Programming 11 August 22nd 05 01:12 AM


All times are GMT +1. The time now is 06:10 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"