VBA to delete a 4 row range based on one cell value

mjayh

New Member
Joined
Oct 21, 2013
Messages
7
Hello, I would be grateful for some assistance as I am a VBA novice. I have a spreadsheet broken out into about 30 4-row ranges, for example (A10:L13). All of the ranges use a using a vlookup argument: =IFERROR(VLOOKUP($A10,Fund_Range,2,FALSE),"") in the second row. Around 15 of the ranges will be populated based on varying data in the fund_range data table, the remainder will be blank. The first row of each range is a header row, I would like the macro to delete the range when there is no value in the second row (the blank ranges). Every attempt I have made starting with other code from the forum has come up empty. I think part of my problem is the vlookup formula existing in these otherwise "blank" rows. Any suggestions would be greatly appreciated.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Although I would have liked it to be more dynamic via ranges, this got the job done for me and I will close it out.Sub BlankCategoryDelete()
'

With Sheets("Review")
.Visible = True
If .Range("A104") = "" Then
.Range("A103:L105").Delete Shift:=xlUp
End If
If .Range("A100") = "" Then
.Range("A99:A102").Delete Shift:=xlUp
End If
If .Range("A96") = "" Then
.Range("A95:L98").Delete Shift:=xlUp
End If
If .Range("A92") = "" Then
.Range("A91:L94").Delete Shift:=xlUp
End If
If .Range("A88") = "" Then
.Range("A87:L90").Delete Shift:=xlUp
End If
If .Range("A84") = "" Then
.Range("A83:L86").Delete Shift:=xlUp
End If
If .Range("A80") = "" Then
.Range("A79:L82").Delete Shift:=xlUp
End If
If .Range("A76") = "" Then
.Range("A75:L78").Delete Shift:=xlUp
End If
If .Range("A72") = "" Then
.Range("A71:L74").Delete Shift:=xlUp
End If
If .Range("A68") = "" Then
.Range("A67:L70").Delete Shift:=xlUp
End If
If .Range("A64") = "" Then
.Range("A63:L66").Delete Shift:=xlUp
End If
If .Range("A60") = "" Then
.Range("A59:L62").Delete Shift:=xlUp
End If
If .Range("A56") = "" Then
.Range("A55:L58").Delete Shift:=xlUp
End If
If .Range("A52") = "" Then
.Range("A51:L54").Delete Shift:=xlUp
End If
If .Range("A48") = "" Then
.Range("A47:L50").Delete Shift:=xlUp
End If
If .Range("A44") = "" Then
.Range("A43:L46").Delete Shift:=xlUp
End If
If .Range("A40") = "" Then
.Range("A39:L42").Delete Shift:=xlUp
End If
If .Range("A36") = "" Then
.Range("A35:L38").Delete Shift:=xlUp
End If
If .Range("A32") = "" Then
.Range("A31:L34").Delete Shift:=xlUp
End If
If .Range("A28") = "" Then
.Range("A27:L30").Delete Shift:=xlUp
End If
If .Range("A24") = "" Then
.Range("A23:L26").Delete Shift:=xlUp
End If
If .Range("A20") = "" Then
.Range("A19:L22").Delete Shift:=xlUp
End If
If .Range("A15") = "" Then
.Range("A14:L18").Delete Shift:=xlUp
End If
If .Range("A11") = "" Then
.Range("A10:L13").Delete Shift:=xlUp
End If

End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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