Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Deleting rows when certain cells are blank

Hi,

I am using this code to delete the row if the cell in column A is blank.
Dim i, j As Integer
Set starta = ActiveSheet.Range("a2")
LR = ActiveSheet.Range("a" & Rows.Count).End(xlUp).Offset(1, 0).Row
For i = LR To 0 Step -1
If starta.Offset(i, 0).Value = 0 Then starta.Offset(i, 0).EntireRow.Delete
Next i

I would then like to delete a row if the cells in columns B, C, D, and E are
all blank even if the cell in column A is not blank

Any ideas?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Deleting rows when certain cells are blank

Matt,

Set starta = ActiveSheet.Range("a2")
LR = ActiveSheet.Range("a" & Rows.Count).End(xlUp).Offset(1, 0).Row
For i = LR To 0 Step -1
If starta.Offset(i, 0).Value = 0 Or _
Application.CountA(starta.Offset(i, 1).Resize(1, 4)) = 0 _
Then starta.Offset(i, 0).EntireRow.Delete
Next i

HTH,
Bernie
MS Excel MVP


"Matt G" wrote in message
...
Hi,

I am using this code to delete the row if the cell in column A is blank.
Dim i, j As Integer
Set starta = ActiveSheet.Range("a2")
LR = ActiveSheet.Range("a" & Rows.Count).End(xlUp).Offset(1, 0).Row
For i = LR To 0 Step -1
If starta.Offset(i, 0).Value = 0 Then starta.Offset(i, 0).EntireRow.Delete
Next i

I would then like to delete a row if the cells in columns B, C, D, and E are
all blank even if the cell in column A is not blank

Any ideas?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Deleting rows when certain cells are blank

Give this macro a try...

Sub DeleteRowsIfBtoEareBlank()
Dim LR As Long, i As Long, R As Range
On Error Resume Next
With ActiveSheet
LR = .Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious).Row
For i = LR To 1 Step -1
Err.Clear
Set R = .Range("B" & i & ":E" & i).SpecialCells(xlCellTypeBlanks)
If Err.Number = 0 Then
If R.Count = 4 Then .Rows(i).Delete
End If
Next
End With
End Sub

--
Rick (MVP - Excel)


"Matt G" wrote in message
...
Hi,

I am using this code to delete the row if the cell in column A is blank.
Dim i, j As Integer
Set starta = ActiveSheet.Range("a2")
LR = ActiveSheet.Range("a" & Rows.Count).End(xlUp).Offset(1, 0).Row
For i = LR To 0 Step -1
If starta.Offset(i, 0).Value = 0 Then starta.Offset(i,
0).EntireRow.Delete
Next i

I would then like to delete a row if the cells in columns B, C, D, and E
are
all blank even if the cell in column A is not blank

Any ideas?


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
deleting rows with blank cells after a specified column? MYR Excel Discussion (Misc queries) 3 January 9th 09 09:13 PM
Deleting blank cells w/o impacting other rows/columns ShagNasty Excel Programming 5 October 26th 08 04:34 PM
Deleting blank (Cells/Rows) in Excel-VBA VexedFist Excel Programming 1 April 6th 07 05:08 AM
Deleting rows with blank cells jim_0068 Excel Programming 15 April 7th 06 08:00 AM
Deleting rows with blank cells Batman Excel Worksheet Functions 10 February 16th 05 06:01 PM


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