Delete rows containing the value blank

jeffreybrown

Well-known Member
Joined
Jul 28, 2004
Messages
5,152
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
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
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:
Upvote 0

Forum statistics

Threads
1,213,558
Messages
6,114,297
Members
448,564
Latest member
ED38

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
Back
Top