Delete Row If Empty Macro
Using: MS OS XP
Excel 2003 I have tried and need some help for some VBA code in a macro. I have a table of about 400 rows. The rows may vary but not be over 400. I need to check the cells in column A. If the cell in column A is empty then I want to delete the entire row and go and check the next cell in column A etc. The rows may vary but they shouldnt exceed 400. -- Richard |
Delete Row If Empty Macro
Select column A
Edit|goto|special check Blanks Edit|Delete|entire row. Richard wrote: Using: MS OS XP Excel 2003 I have tried and need some help for some VBA code in a macro. I have a table of about 400 rows. The rows may vary but not be over 400. I need to check the cells in column A. If the cell in column A is empty then I want to delete the entire row and go and check the next cell in column A etc. The rows may vary but they shouldnt exceed 400. -- Richard -- Dave Peterson |
Delete Row If Empty Macro
And if you need a macro:
Option Explicit Sub testme() On Error Resume Next ActiveSheet.Range("a:A").Cells.SpecialCells(xlCell TypeBlanks).EntireRow.Delete On Error GoTo 0 End Sub Dave Peterson wrote: Select column A Edit|goto|special check Blanks Edit|Delete|entire row. Richard wrote: Using: MS OS XP Excel 2003 I have tried and need some help for some VBA code in a macro. I have a table of about 400 rows. The rows may vary but not be over 400. I need to check the cells in column A. If the cell in column A is empty then I want to delete the entire row and go and check the next cell in column A etc. The rows may vary but they shouldnt exceed 400. -- Richard -- Dave Peterson -- Dave Peterson |
Delete Row If Empty Macro
Richard
Sub delete_rows() Dim RowNdx As Long Dim LastRow As Long LastRow = ActiveSheet.UsedRange.Rows.Count For RowNdx = LastRow To 1 Step -1 If Cells(RowNdx, "A").Value = "" Then Rows(RowNdx).Delete End If Next RowNdx End Sub Note: you don't need a macro to do this. Select column A and F5SpecialBlanksOK EditDeleteEntire Row. Gord Dibben MS Excel MVP On Fri, 20 Jan 2006 14:21:03 -0800, "Richard" wrote: Using: MS OS XP Excel 2003 I have tried and need some help for some VBA code in a macro. I have a table of about 400 rows. The rows may vary but not be over 400. I need to check the cells in column A. If the cell in column A is empty then I want to delete the entire row and go and check the next cell in column A etc. The rows may vary but they shouldn’t exceed 400. |
All times are GMT +1. The time now is 02:07 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com