Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Count of all non empty "records"

Hi all,

I would like to get a count of all non empty "records" (range of Ax:Px) and tried to use this code,
but it keeps returning 32767...is this the correct way?

intRow = 2
RecordCount = 0

For i = intRow To Rows.Count
If Sheet2.Range("A" & intRow & ":P" & intRow).Value < "" Then
RecordCount = RecordCount + 1
Else
Exit For
End If
Next

Thank you

Cindi
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Count of all non empty "records"

You may want to try this (You can also use the Offset function to move
around cells):

Public Sub Test()
Dim ntRow As Integer
Dim RecordCount As Integer
Worksheets(1).Select
ntRow = 2
RecordCount = 0
For Each cell In Range("A1:P65536")
If cell.Value < "" Then
RecordCount = RecordCount + 1
End If

Next
MsgBox (RecordCount)
End Sub

"Cynthia" wrote in message
news:AUsmc.42375$I%1.2758026@attbi_s51...
Hi all,

I would like to get a count of all non empty "records" (range of Ax:Px)

and tried to use this code,
but it keeps returning 32767...is this the correct way?

intRow = 2
RecordCount = 0

For i = intRow To Rows.Count
If Sheet2.Range("A" & intRow & ":P" & intRow).Value < "" Then
RecordCount = RecordCount + 1
Else
Exit For
End If
Next

Thank you

Cindi



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Count of all non empty "records"

Hi William,


Application.CountA(Range("A1:P65536"))

---
Norman

"William Ryan eMVP" wrote in message
...
You may want to try this (You can also use the Offset function to move
around cells):

Public Sub Test()
Dim ntRow As Integer
Dim RecordCount As Integer
Worksheets(1).Select
ntRow = 2
RecordCount = 0
For Each cell In Range("A1:P65536")
If cell.Value < "" Then
RecordCount = RecordCount + 1
End If

Next
MsgBox (RecordCount)
End Sub

"Cynthia" wrote in message
news:AUsmc.42375$I%1.2758026@attbi_s51...
Hi all,

I would like to get a count of all non empty "records" (range of Ax:Px)

and tried to use this code,
but it keeps returning 32767...is this the correct way?

intRow = 2
RecordCount = 0

For i = intRow To Rows.Count
If Sheet2.Range("A" & intRow & ":P" & intRow).Value < "" Then
RecordCount = RecordCount + 1
Else
Exit For
End If
Next

Thank you

Cindi





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Count of all non empty "records"

Right on brother. My VBA is quite rusty but I'm getting in back.

Thanks,

Bill
"Norman Jones" wrote in message
...
Hi William,


Application.CountA(Range("A1:P65536"))

---
Norman

"William Ryan eMVP" wrote in message
...
You may want to try this (You can also use the Offset function to move
around cells):

Public Sub Test()
Dim ntRow As Integer
Dim RecordCount As Integer
Worksheets(1).Select
ntRow = 2
RecordCount = 0
For Each cell In Range("A1:P65536")
If cell.Value < "" Then
RecordCount = RecordCount + 1
End If

Next
MsgBox (RecordCount)
End Sub

"Cynthia" wrote in message
news:AUsmc.42375$I%1.2758026@attbi_s51...
Hi all,

I would like to get a count of all non empty "records" (range of

Ax:Px)
and tried to use this code,
but it keeps returning 32767...is this the correct way?

intRow = 2
RecordCount = 0

For i = intRow To Rows.Count
If Sheet2.Range("A" & intRow & ":P" & intRow).Value < "" Then
RecordCount = RecordCount + 1
Else
Exit For
End If
Next

Thank you

Cindi







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 136
Default Count of all non empty "records"

Try this:

Sub test()
Dim lastrow As Long, i As Long, recordcount As Long
Dim j As Integer
Dim msg As String
lastrow = Range("a:p").Find("*", SearchOrder:=xlByRows,
SearchDirection:=xlPrevious).Row
For i = 2 To lastrow
For j = 1 To 16
If Cells(i, j).Value < "" Then
recordcount = recordcount + 1
Exit For
End If
Next j
Next i
msg = "There are " & recordcount & " rows below " _
& "row 1 which contain a non-blank cell in columns A to P."
MsgBox (msg)
End Sub

Cynthia wrote:
Hi all,

I would like to get a count of all non empty "records" (range of Ax:Px)
and tried to use this code, but it keeps returning 32767...is this the
correct way?

intRow = 2
RecordCount = 0

For i = intRow To Rows.Count
If Sheet2.Range("A" & intRow & ":P" & intRow).Value < "" Then
RecordCount = RecordCount + 1
Else
Exit For
End If
Next

Thank you

Cindi



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Count of all non empty "records"

JWolf wrote:

Try this:

Sub test()
Dim lastrow As Long, i As Long, recordcount As Long
Dim j As Integer
Dim msg As String
lastrow = Range("a:p").Find("*", SearchOrder:=xlByRows,
SearchDirection:=xlPrevious).Row
For i = 2 To lastrow
For j = 1 To 16
If Cells(i, j).Value < "" Then
recordcount = recordcount + 1
Exit For
End If
Next j
Next i
msg = "There are " & recordcount & " rows below " _
& "row 1 which contain a non-blank cell in columns A to P."
MsgBox (msg)
End Sub

Cynthia wrote:

Hi all,

I would like to get a count of all non empty "records" (range of
Ax:Px) and tried to use this code, but it keeps returning 32767...is
this the correct way?

intRow = 2
RecordCount = 0

For i = intRow To Rows.Count
If Sheet2.Range("A" & intRow & ":P" & intRow).Value < "" Then
RecordCount = RecordCount + 1
Else
Exit For
End If
Next

Thank you

Cindi

Thanks Mr Wolf...

That does return the number of rows that do not contain any data!

Cindi
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Count of all non empty "records"

Hi cynthia try this

=SUM(IF(FREQUENCY(IF(LEN(Range1)0,MATCH(Range1,Ra nge1,0),""),
IF(LEN(Range1)0,MATCH(Range1,Range1,0),""))0,1))

This formula will return the value of all unique non blank entries i
the range....i have used this.

HTH

Simo

--
Message posted from http://www.ExcelForum.com

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
Create Pivot Table Data with Column "Sum" rather than "count" defa Johnny_99[_2_] Excel Discussion (Misc queries) 2 January 2nd 10 03:25 PM
Pivot tables - how do I change default from "count of" to "sum of" Cathy H Excel Worksheet Functions 2 November 19th 08 01:31 AM
Count(if(A3:A200)="100000" if (B3:B200="Y") and (C3:C200=Z))) Prasad Excel Discussion (Misc queries) 2 June 27th 06 06:39 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
count of records with 2 or more "options" selected Monish Excel Worksheet Functions 1 October 23rd 05 03:10 AM


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