Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default testing for non-empty cells

I need to test an entire column to see if there are any non-blank cells in
the column. I've tried writing an expression using CountA(), but I can't
get it to work.

Can anyone tell me how I could test, say, Column C, to see if there are any
blank cells in that column?

Thank you in advance.

Paul


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default testing for non-empty cells

Hello Paul

Dim intNo as Integer
intNo =
Application.CountBlank(ActiveWorkbook.Worksheets(1 ).Range("C:C"))

Heiko
:-)
"Paul James" wrote:

I need to test an entire column to see if there are any non-blank cells in
the column. I've tried writing an expression using CountA(), but I can't
get it to work.

Can anyone tell me how I could test, say, Column C, to see if there are any
blank cells in that column?

Thank you in advance.

Paul



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default testing for non-empty cells

Paul,

This is one way to do it. I've used a range in the function to ensure that
if this is used as a UDF it can reference another sheet if needed. If your
in XL97 you'll need to change the line that sets lrow to 16384 (or whatever
the max rows is).

Public Function IsColumnEmpty(rngTest As Range) As Boolean
Dim lRow As Long
Dim nCol As Integer
nCol = rngTest.Column
With rngTest.Parent
lRow = .Cells(65536, nCol).End(xlUp).Row
If lRow = 1 And IsEmpty(.Cells(lRow, nCol).Value) Then _
IsColumnEmpty = True
End With
End Function

Robin Hammond
www.enhanceddatasystems.com
Check out our XspandXL add-in


"Paul James" wrote in message
news:ULJWa.46245$uu5.5082@sccrnsc04...
I need to test an entire column to see if there are any non-blank cells in
the column. I've tried writing an expression using CountA(), but I can't
get it to work.

Can anyone tell me how I could test, say, Column C, to see if there are

any
blank cells in that column?

Thank you in advance.

Paul




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default testing for non-empty cells

Paul,

Doesn't =COUNTA(C:C) tell you if there are some non-blank cells. It picks up
formulae and values. The number of rows is 65536 (97 and above), so if it's
less than that number there are balnsk

=IF(COUNTA(C:C)<65536,"you have blanks","no blanks")

--

HTH

Bob Phillips

"Paul James" wrote in message
news:ULJWa.46245$uu5.5082@sccrnsc04...
I need to test an entire column to see if there are any non-blank cells in
the column. I've tried writing an expression using CountA(), but I can't
get it to work.

Can anyone tell me how I could test, say, Column C, to see if there are

any
blank cells in that column?

Thank you in advance.

Paul




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default testing for non-empty cells

or just change it to:

Public Function IsColumnEmpty(rngTest As Range) As Boolean
Dim lRow As Long
Dim nCol As Integer
nCol = rngTest.Column
With rngTest.Parent
lRow = .Cells(rows.count, nCol).End(xlUp).Row
If lRow = 1 And IsEmpty(.Cells(1, nCol).Value) Then _
IsColumnEmpty = True
End With
End Function

But if using as a UDF, might as well just use the countA function directly.

Regards,
Tom Ogilvy


Heiko wrote in message
...
Dear Robin,
thats good too
but only if one is using <= Excel 5 he has to modify the maximum
Rowcount.

Heiko
:-)
"Robin Hammond" wrote:

Paul,

This is one way to do it. I've used a range in the function to ensure

that
if this is used as a UDF it can reference another sheet if needed. If

your
in XL97 you'll need to change the line that sets lrow to 16384 (or

whatever
the max rows is).

Public Function IsColumnEmpty(rngTest As Range) As Boolean
Dim lRow As Long
Dim nCol As Integer
nCol = rngTest.Column
With rngTest.Parent
lRow = .Cells(65536, nCol).End(xlUp).Row
If lRow = 1 And IsEmpty(.Cells(lRow, nCol).Value) Then _
IsColumnEmpty = True
End With
End Function

Robin Hammond
www.enhanceddatasystems.com
Check out our XspandXL add-in


"Paul James" wrote in message
news:ULJWa.46245$uu5.5082@sccrnsc04...
I need to test an entire column to see if there are any non-blank cells

in
the column. I've tried writing an expression using CountA(), but I

can't
get it to work.

Can anyone tell me how I could test, say, Column C, to see if there are

any
blank cells in that column?

Thank you in advance.

Paul









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default testing for non-empty cells

=if(countA(C:C)=0,"All Blank","Blanks: "&rows(C:C)-CountA(C:C))

if you want to find blanks only up to the last used cell

=IF(COUNTA(C:C)=0,"All Blank","Blanks:
"&MATCH(9.99999999999999E+307,C:C)-COUNTA(C:C))

if only numeric values are contained in column C or for only non-numeric
entries:

=IF(COUNTA(C:C)=0,"All Blank","Blanks:
"&MATCH(REPT("Z",255),C:C)-COUNTA(C:C))

Actually, the restriction is only to the type of data in the last populated
cell.



--
Regards,
Tom Ogilvy


Paul James wrote in message
news:ULJWa.46245$uu5.5082@sccrnsc04...
I need to test an entire column to see if there are any non-blank cells in
the column. I've tried writing an expression using CountA(), but I can't
get it to work.

Can anyone tell me how I could test, say, Column C, to see if there are

any
blank cells in that column?

Thank you in advance.

Paul




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default testing for non-empty cells

Great information.

Thank you, Heiko, Robin, Tom an Bob.


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
Testing Cells Paul New Users to Excel 6 June 8th 07 07:14 PM
TESTING A RANGE OF CELLS Richard[_2_] New Users to Excel 3 April 1st 07 02:52 PM
TESTING A RANGE OF CELLS Richard[_2_] Excel Worksheet Functions 3 April 1st 07 02:52 PM
Testing Spreadsheet Cells while in a Macro Amaross Excel Discussion (Misc queries) 2 May 2nd 06 09:03 PM
Excel - Autom. Filter "Empty / Non Empty cells" should come first Rom Excel Discussion (Misc queries) 0 August 10th 05 04:32 PM


All times are GMT +1. The time now is 09:44 AM.

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"