Delete rows containing the value blank

jeffreybrown

Well-known Member
Joined
Jul 28, 2004
Messages
5,145
The first part of the code I have working fine.

All of the row containing the value "Blank" in column "B" get deleted, but now I need all rows on Sheet3 with an offset of 3 to get deleted also.

On Sheet2 the values start at row 5, but on Sheet3 row 8.

Code:
Sub delblank()
Dim LR As Long, i As Long
LR = Sheets("Sheet2").Range("B" & Rows.Count).End(xlUp).Row
For i = LR To 5 Step -1
    With Sheets("Sheet2").Range("B" & i)
        If Range("B" & i).Value = "Blank" Then Rows(i).Delete
    End With
'    With Sheets("Sheet3")
'        .Rows(i - 3).Delete
'    End With
    Next i
End Sub
 

Some videos you may like

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

taigovinda

Well-known Member
Joined
Mar 28, 2007
Messages
2,639
If I understand you right, you should be able to fix it by changing your "-3" to "+3" in the commented part of the code. For instance, when row 15 is deleted on sheet 2, you want to delete row 18 on sheet 3. Hope that helps.

Edit: I see, there's slightly more change maybe needed... what about this:

Code:
Sub delblank()
Dim LR As Long, i As Long
LR = Sheets("Sheet2").Range("B" & Rows.Count).End(xlUp).Row
For i = LR To 5 Step -1
        If Sheets("Sheet2").Range("B" & i).Value = "Blank" Then 
           Sheets("Sheet2").Rows(i).Delete
           Sheets("Sheet3").Rows(i + 3).Delete
        End if
    Next i
End Sub
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,122,232
Messages
5,594,956
Members
413,954
Latest member
mrsandy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top