VBA - clear contents of a particular range if cell is blank

ExcelMike21

New Member
Joined
Mar 30, 2020
Messages
6
Office Version
  1. 365
  2. 2016
  3. 2013
Platform
  1. Windows
  2. Mobile
Hi

Found some really useful tips on the board but this is my first post as I cannot find the answer after searching.

As above, I am trying to write a vba that will do the following:

If any cells in range C8:C32 are blank, then I would like to automatically clear the contents in the adjacent cells in columns D:T.

For example, if C8 is blank, I need to automatically clear contents in cells D8:T8, however, it then needs to look at C9, C10 all the way through to C32 (regardless of what the previous event was for the row above).

For context, range C8:C32 (named "Dates"), contains dates that are automatically populated each month, however, they move up or down depending on the day of the month. i.e. Wednesday 1st April would start in C10 (C8 being Monday, C9 being Tuesday). Please also note, when I say C8:C32 are blank, I mean they contain a formula that is currently showing the cell to be blank, not fully empty.

I have played around with various things I've seen on the forum and the closest I can get is as follows:

VBA Code:

But, I'm struggling to get the above to work for the full range of cells and it's as if I would need to type that out for every cell/row I want it to apply to (and I know there must be a simpler way!)

Really appreciate any help or advice.

Please let me know if you need more information or if anything doesn't make sense!

Thanks,
Michael
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
14,048
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
Happy it helps and welcome to the forum (btw you don't need to requote whole posts or code. Just quote any relevant parts [select the text and click the reply icon that comes up or if it is code then copy/paste the relevant part, select it and click the <vba/> icon]. If you don't need any quotes then type directly in the box at the bottom of the page with your profile icon next to it and click post reply).
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Watch MrExcel Video

Forum statistics

Threads
1,129,512
Messages
5,636,764
Members
416,939
Latest member
Rajakumaran

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