Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Counting number of rows that are not N/A

I have the following

RowCount = Cells(Rows.Count, "A").End(xlUp).Row

However, column A has several entries of #N/A with the function NA().

I need to count the number of entries in column A that are not NA and the
number of entries that ARE NA. How would I accomplish that?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Counting number of rows that are not N/A

You could just count the number of entries in column A with the
=NA()
formula:


Sub gsnu()
Dim r As Range, r2 As Range
RowCount = Cells(Rows.Count, "A").End(xlUp).Row
Set r2 = Intersect(ActiveSheet.UsedRange, Range("A:A"))
For Each r In r2
If r.Formula = "=NA()" Then
i = i + 1
End If
Next
MsgBox (i)
End Sub

so RowCount is the total
i is the number of #N/As
RowCount-i is the number without #N/A
--
Gary's Student


"Barb Reinhardt" wrote:

I have the following

RowCount = Cells(Rows.Count, "A").End(xlUp).Row

However, column A has several entries of #N/A with the function NA().

I need to count the number of entries in column A that are not NA and the
number of entries that ARE NA. How would I accomplish that?

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Counting number of rows that are not N/A

looping is always an option, but faster is

numNA = Application.Countif(Range("A:A"),"#N/A")
nonNA = lastrow - numNA

If the only error value is NA

set rng = Columns(1).SpecialCells(xlFormulas,xlErrors)
numNa = rng.count
nonNA = lastrow = rng.count

--
Regards,
Tom Ogilvy

"Gary''s Student" wrote:

You could just count the number of entries in column A with the
=NA()
formula:


Sub gsnu()
Dim r As Range, r2 As Range
RowCount = Cells(Rows.Count, "A").End(xlUp).Row
Set r2 = Intersect(ActiveSheet.UsedRange, Range("A:A"))
For Each r In r2
If r.Formula = "=NA()" Then
i = i + 1
End If
Next
MsgBox (i)
End Sub

so RowCount is the total
i is the number of #N/As
RowCount-i is the number without #N/A
--
Gary's Student


"Barb Reinhardt" wrote:

I have the following

RowCount = Cells(Rows.Count, "A").End(xlUp).Row

However, column A has several entries of #N/A with the function NA().

I need to count the number of entries in column A that are not NA and the
number of entries that ARE NA. How would I accomplish that?

Thanks

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
Counting Number of Discrepancies between 2 rows RobFJ[_3_] Excel Worksheet Functions 2 February 16th 10 12:47 PM
Counting number of rows Lynne Mawson New Users to Excel 1 May 8th 08 05:56 PM
Counting number of rows Lynne Mawson New Users to Excel 0 May 8th 08 03:53 PM
counting the number of equal rows Malte Lindner New Users to Excel 1 April 15th 06 09:48 PM
Counting the number of rows blurboiboi Excel Worksheet Functions 1 July 13th 05 11:20 AM


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

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

About Us

"It's about Microsoft Excel"