Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Is there a function in VBA to find out if entire column is empty?

Hi, VBA experts:

Can anyone inform me if VBA has a function that tells if a coumn in a
worksheet is empty?

I wrote the following code, but it does not work. I could write some
code to check each row of the column, but I believe VBA must have a
function to take care of this. Please help. Thanks.


Cells(3, 6).Select
Range(ActiveCell, ActiveCell.End(xlDown)).Select

If Selection.Value = " " Then

noData = True

Esle

Selection.Copy

End If


Thank you very much.

KHW

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Is there a function in VBA to find out if entire column is empty?

Maybe...

if application.counta(range("F:F")) 0 then
'there's something in column F
else
'all of F is empty
end if



HelpEachOther wrote:

Hi, VBA experts:

Can anyone inform me if VBA has a function that tells if a coumn in a
worksheet is empty?

I wrote the following code, but it does not work. I could write some
code to check each row of the column, but I believe VBA must have a
function to take care of this. Please help. Thanks.

Cells(3, 6).Select
Range(ActiveCell, ActiveCell.End(xlDown)).Select

If Selection.Value = " " Then

noData = True

Esle

Selection.Copy

End If


Thank you very much.

KHW


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Is there a function in VBA to find out if entire column is empty?


Dave:

Thank you very much for your quick response. I have tried your
suggestion and it works!!

Thank you!!!

KHW


*** Sent via Developersdex http://www.developersdex.com ***
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Is there a function in VBA to find out if entire column is empty?

Give this a try...

Sub test()
MsgBox EmptyColumn("A")
MsgBox EmptyColumn("B")
MsgBox EmptyColumn("C")

End Sub

Public Function EmptyColumn(ByVal ColumnReference As String) As Boolean
Columns(ColumnReference).Select
If Application.WorksheetFunction.CountA(Columns(Colum nReference)) 0 Then
EmptyColumn = False
Else
EmptyColumn = True
End If
End Function

--
HTH...

Jim Thomlinson


"HelpEachOther" wrote:

Hi, VBA experts:

Can anyone inform me if VBA has a function that tells if a coumn in a
worksheet is empty?

I wrote the following code, but it does not work. I could write some
code to check each row of the column, but I believe VBA must have a
function to take care of this. Please help. Thanks.


Cells(3, 6).Select
Range(ActiveCell, ActiveCell.End(xlDown)).Select

If Selection.Value = " " Then

noData = True

Esle

Selection.Copy

End If


Thank you very much.

KHW


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Is there a function in VBA to find out if entire column is empty?

Dim LastRow As Long

LastRow = 65536
If IsEmpty(Cells(LastRow, "A")) Then
LastRow = Cells(LastRow, "A").End(xlUp).Row
If LastRow = 1 And IsEmpty(Cells(LastRow, "A")) Then LastRow = 0
End If

Returns the last row in a column with something in it. Returns zero if the
entire column is empty

"HelpEachOther" wrote:

Hi, VBA experts:

Can anyone inform me if VBA has a function that tells if a coumn in a
worksheet is empty?

I wrote the following code, but it does not work. I could write some
code to check each row of the column, but I believe VBA must have a
function to take care of this. Please help. Thanks.


Cells(3, 6).Select
Range(ActiveCell, ActiveCell.End(xlDown)).Select

If Selection.Value = " " Then

noData = True

Esle

Selection.Copy

End If


Thank you very much.

KHW


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
EXCEL function;find string in entire column & return cell referenc Audit Compliance Man Excel Worksheet Functions 2 April 21st 23 10:24 AM
How to SUM entire column, but only when adjacent cell is not empty SteveDJ Excel Worksheet Functions 3 May 7th 10 09:16 PM
Find Column heading and then Delete entire column Kobayashi[_58_] Excel Programming 4 October 17th 05 09:09 PM
Is there a test to see if an entire row or column is empty? Henry Stock Excel Programming 3 February 25th 05 05:50 PM
Find the first empty column Simon Excel Programming 3 September 6th 04 12:31 PM


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