Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Delete entire rows where there is a blank in column A

Hello,

Could someone please advise on a macro code that would do the following:

If there is a blank cell in column A, then delete the entire row . I
need this to loop around from A2:A60000.

Any help would be greatly appreciated.

Thanks,

Longbow :-)

Live Long and Prosper :)

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Delete entire rows where there is a blank in column A

The easiest might be to sort and then delete

or if you don't want to sort
Sub deleteblanks()
Columns(1).SpecialCells(xlBlanks).Delete
End Sub

--
Don Guillett
SalesAid Software

"Chris Hankin" wrote in message
...
Hello,

Could someone please advise on a macro code that would do the following:

If there is a blank cell in column A, then delete the entire row . I
need this to loop around from A2:A60000.

Any help would be greatly appreciated.

Thanks,

Longbow :-)

Live Long and Prosper :)

*** Sent via Developersdex
http://www.developersdex.com ***


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Delete entire rows where there is a blank in column A

Hi Chris

Try this
http://www.rondebruin.nl/specialcells.htm


--
Regards Ron De Bruin
http://www.rondebruin.nl



"Chris Hankin" wrote in message ...
Hello,

Could someone please advise on a macro code that would do the following:

If there is a blank cell in column A, then delete the entire row . I
need this to loop around from A2:A60000.

Any help would be greatly appreciated.

Thanks,

Longbow :-)

Live Long and Prosper :)

*** Sent via Developersdex http://www.developersdex.com ***



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Delete entire rows where there is a blank in column A

One way

Sub Macro1()
'
Dim cell As Range

For Each cell In Range("A2":A6000")
If cell.Value = "" Then
cell.EntireRow.Delete
End If
Next cell
End Sub

"Chris Hankin" wrote in message
...
Hello,

Could someone please advise on a macro code that would do the following:

If there is a blank cell in column A, then delete the entire row . I
need this to loop around from A2:A60000.

Any help would be greatly appreciated.

Thanks,

Longbow :-)

Live Long and Prosper :)

*** Sent via Developersdex http://www.developersdex.com ***



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Delete entire rows where there is a blank in column A

Thanks to Alf Bryn, Don Guillett and Ron de Bruin for your help - very
much appreciated. Unfortunately, these macro codes worked but did not
delete all the rows that had blanks in column A.

Alf's code worked the best but I had the following problem:

At the moment I have 6 rows of data that I wish to keep and each of
these rows contains data in column A. However, in column S and Y, I
have approximately 60,000 rows of data that has no data in their
corresponding column A. As this is a dynamic spreadsheet (it gets
larger over time) I need to delete all rows that contain data in columns
S and Y but have no data in column A.

With Alf's code, what happened was that when the code applied to row 7
(first blank row in column A) it deleted OK. However, after it deleted
this row, the row became "A7" again and again... and consequently the
code did not continue deleting as it contined its loop to row 8, 9, 10
...

If anyone can please help that would be great.

Kind regards,

Longbow :-)

Live Long and Prosper :)

*** Sent via Developersdex http://www.developersdex.com ***


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Delete entire rows where there is a blank in column A

hi Chris

Alf's code is wrong because it not delete from the bottom up
Maybe you cells are not really blank ??

See this page for looping examples
http://www.rondebruin.nl/delete.htm



--
Regards Ron De Bruin
http://www.rondebruin.nl



"Chris Hankin" wrote in message ...
Thanks to Alf Bryn, Don Guillett and Ron de Bruin for your help - very
much appreciated. Unfortunately, these macro codes worked but did not
delete all the rows that had blanks in column A.

Alf's code worked the best but I had the following problem:

At the moment I have 6 rows of data that I wish to keep and each of
these rows contains data in column A. However, in column S and Y, I
have approximately 60,000 rows of data that has no data in their
corresponding column A. As this is a dynamic spreadsheet (it gets
larger over time) I need to delete all rows that contain data in columns
S and Y but have no data in column A.

With Alf's code, what happened was that when the code applied to row 7
(first blank row in column A) it deleted OK. However, after it deleted
this row, the row became "A7" again and again... and consequently the
code did not continue deleting as it contined its loop to row 8, 9, 10
..

If anyone can please help that would be great.

Kind regards,

Longbow :-)

Live Long and Prosper :)

*** Sent via Developersdex http://www.developersdex.com ***



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Delete entire rows where there is a blank in column A

Thanks Ron for the information. I visited the site you recommended and
used the following macro code which worked very well:

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

Kind regards,

Chris.

Live Long and Prosper :)

*** Sent via Developersdex http://www.developersdex.com ***
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Delete entire rows where there is a blank in column A

I posted that macro in my first reply to you ?

--
Regards Ron De Bruin
http://www.rondebruin.nl



"Chris Hankin" wrote in message ...
Thanks Ron for the information. I visited the site you recommended and
used the following macro code which worked very well:

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

Kind regards,

Chris.

Live Long and Prosper :)

*** Sent via Developersdex http://www.developersdex.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
How to Delete entire rows by selecting different text in column A Doug[_5_] Excel Discussion (Misc queries) 2 November 20th 09 02:03 PM
Easiest way to delete blank cells in column (not entire row) sramsey Excel Discussion (Misc queries) 4 February 16th 06 04:28 PM
To Delete the specific rows when blank is found on column A ddiicc Excel Programming 3 August 5th 05 05:32 AM
Delete Entire Row If Column C is Blank John Excel Programming 5 July 19th 04 10:23 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM


All times are GMT +1. The time now is 03:16 AM.

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"