Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 36
Default Delete row with empty cell in column

I have a worksheet with a column named DATE. Some of the date cells are
empty. I want a macro to delete all of the rows in which the date cell is
empty.


Gene Augustin

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default Delete row with empty cell in column

Try after changing A in the second row to the column you having DATE

Sub deleteRow()
ColumntoDelete = "A"
For i = Cells(Rows.Count, ColumntoDelete).End(xlUp).Row To 1 Step -1
If Cells(i, ColumntoDelete) = "" Then Cells(i, "A").EntireRow.Delete
Next i
End Sub

"Gene Augustin" wrote:

I have a worksheet with a column named DATE. Some of the date cells are
empty. I want a macro to delete all of the rows in which the date cell is
empty.


Gene Augustin


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 857
Default Delete row with empty cell in column

Hi,

Here is code to delete all rows which have blank cells in column A. You can
modify this to delete all cells of many different types and for any column.

Sub DeleteRows()
Range("A1:A" &
Range("A65536").End(xlUp).Row).SpecialCells(xlCell TypeBlanks).EntireRow.Delete
End Sub

The advantage of this type of code is it uses Excel's built in feature and
therefor runs very fast, in fact, between 60-100 times faster than loops.

In this case I am deleting the entire row but you can replace the
..EntireRow.Delete with .Delete Shift:=XLUp

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"Gene Augustin" wrote:

I have a worksheet with a column named DATE. Some of the date cells are
empty. I want a macro to delete all of the rows in which the date cell is
empty.


Gene Augustin


  #4   Report Post  
Member
 
Location: Sweden
Posts: 30
Default

Place a control box on the sheet from the control box.
Double click the command button to open code window and paste following codes
Code:
Private Sub CommandButton1_Click()
Dim row As Integer, col As Integer
row = 1
col = 1

For row = 1 To 100
    If Sheet1.Cells(row, col).Value = "" Then
        Sheet1.Rows(row).Delete
    End If
Next
End Sub


Chris
------
Convert your Excel spreadsheet into an online calculator.
http://www.spreadsheetconverter.com
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Delete row with empty cell in column


Chris Bode;260396 Wrote:
Place a control box on the sheet from the control box.
Double click the command button to open code window and paste following
codes

Code:
--------------------

Private Sub CommandButton1_Click()
Dim row As Integer, col As Integer
row = 1
col = 1

For row = 1 To 100
If Sheet1.Cells(row, col).Value = "" Then
Sheet1.Rows(row).Delete
End If
Next
End Sub

--------------------




Chris
------
Convert your Excel spreadsheet into an online calculator.
'SpreadsheetConverter - Convert Excel into live and calculating web
pages' (http://www.spreadsheetconverter.com)




--
Chris Bode


Deleting like that is not good practice, when deleting you should
delete from last to first as per Sheeloo's answer!


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=72639

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
Go to last non-empty cell in column Fred Holmes Excel Discussion (Misc queries) 8 January 22nd 09 10:56 PM
Delete Empty Cell With Formula [email protected] Excel Discussion (Misc queries) 4 January 26th 08 03:02 PM
find first empty cell in column and start transpose next row in that cell ali Excel Discussion (Misc queries) 6 July 21st 07 11:55 PM
Delete empty rows with cell type 2 FrankNL Excel Discussion (Misc queries) 1 May 3rd 06 11:10 AM
Using last cell in a column that is not empty in a calculation Leo V. Excel Worksheet Functions 0 February 24th 06 06:33 AM


All times are GMT +1. The time now is 07:00 PM.

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"