Delete Cells based on Blank Cell

Buns1976

Board Regular
Joined
Feb 11, 2019
Messages
194
Office Version
  1. 365
Platform
  1. Windows
Hi Everyone,
I'm looking for a macro to delete data from cells D:E if cell A is blank in any given row up to 500. I can't use Delete Row as there is data that needs to stay from column G:R.

Does anyone have a solution?

Thanks,
B
B
PIC.jpg
 
Last edited:

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Does this do what you want?

VBA Code:
Sub Del_Rws()
  Range("A1:A" & Range("D" & Rows.Count).End(xlUp).Row).SpecialCells(xlBlanks).Resize(, 5).Delete Shift:=xlUp
End Sub

BTW, I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Also consider XL2BB for providing sample data to make it easier for helpers by not having to manually type out sample data to test with.
 
Upvote 0
Solution
Does this do what you want?

VBA Code:
Sub Del_Rws()
  Range("A1:A" & Range("D" & Rows.Count).End(xlUp).Row).SpecialCells(xlBlanks).Resize(, 5).Delete Shift:=xlUp
End Sub

BTW, I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Also consider XL2BB for providing sample data to make it easier for helpers by not having to manually type out sample data to test with.
Yes Sir! It works very well. Thank you very much and I did update my version and platform. Having an issue with XL2BB though. Defender doesn't like the macros.

Thanks again!
B
 
Upvote 0

Forum statistics

Threads
1,214,970
Messages
6,122,514
Members
449,088
Latest member
RandomExceller01

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