Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default How to remove rows with the first cell blank

Try this for column A

Sub DeleteBlankRows_2()
'This macro delete all rows with a blank cell in column A
'If there are no blanks or there are too many areas you see a MsgBox
Dim CCount As Long
On Error Resume Next

With Columns("A") ' You can also use a range like this
Range("A1:A8000")

CCount = .SpecialCells(xlCellTypeBlanks).Areas(1).Cells.Cou nt

If CCount = 0 Then
MsgBox "There are no blank cells"
ElseIf CCount = .Cells.Count Then
MsgBox "There are more then 8192 areas"
Else
.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End If

End With

On Error GoTo 0
End Sub


--



Regards Ron de Bruin
http://www.rondebruin.nl



"Grd" wrote in message
...
Hi ,

I have a block of data from a database export. I need to get rid of rows
which have the first cell blank.

I need to automate this. At the moment I do it manually.

Can this be done in excel vBA. Any help greatly appreciated.

Suzanne


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default How to remove rows with the first cell blank

This works BEAUTIFULLY!!

"Ron de Bruin" wrote:

Try this for column A

Sub DeleteBlankRows_2()
'This macro delete all rows with a blank cell in column A
'If there are no blanks or there are too many areas you see a MsgBox
Dim CCount As Long
On Error Resume Next

With Columns("A") ' You can also use a range like this
Range("A1:A8000")

CCount = .SpecialCells(xlCellTypeBlanks).Areas(1).Cells.Cou nt

If CCount = 0 Then
MsgBox "There are no blank cells"
ElseIf CCount = .Cells.Count Then
MsgBox "There are more then 8192 areas"
Else
.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End If

End With

On Error GoTo 0
End Sub


--



Regards Ron de Bruin
http://www.rondebruin.nl



"Grd" wrote in message
...
Hi ,

I have a block of data from a database export. I need to get rid of rows
which have the first cell blank.

I need to automate this. At the moment I do it manually.

Can this be done in excel vBA. Any help greatly appreciated.

Suzanne



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
How do I remove LOTS of blank rows at once brewster56 Excel Discussion (Misc queries) 7 September 10th 09 02:50 PM
gang remove blank rows swell estimator[_2_] Excel Discussion (Misc queries) 13 September 15th 08 11:37 PM
Need macro to remove blank rows Bob Excel Programming 7 June 21st 06 01:21 PM
remove or hide blank rows Erik Beijlen via OfficeKB.com Excel Discussion (Misc queries) 1 February 1st 05 01:17 PM
Remove blank rows from combobox Steph[_3_] Excel Programming 1 June 25th 04 05:37 PM


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