Clear entire rows if cell is blank

jordanburch

Active Member
Joined
Jun 10, 2016
Messages
440
Office Version
  1. 2016
Hey All,

I am trying to create a macro to clear the rows if a cell is blank. It has to be dynamic because sometimes the cell will or wont be blank. If any cell in the range C8:c17 is blank i want it to clear that entire row. It can clear a range if that makes it faster or easier the range would be A8:J17. Any help would be greatly appreciated!

Thanks,

J
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Do you want this to run automatically, or do you want a macro that you can run whenever you want?
If automatically, how are the cells in C8:C17 being updated?
 
Upvote 0
Are the cells actually empty, or do they have a formula that returns ""
 
Upvote 0
i want to run it whenever I want I will call it when the user clicks a button.

The cells are actually empty. They do have a dropdown box that the user has to select a value and then it inputs that value if that makes any difference to you.

J
 
Upvote 0
Here is one way, though I wonder if there may be a faster way to do it using Special Cells:
VBA Code:
Sub MyClearRows()

    Dim cell As Range
    
    Application.ScreenUpdating = False
    
    For Each cell In Range("C8:C17")
        If cell = "" Then Rows(cell.Row).ClearContents
    Next cell
    
    Application.ScreenUpdating = True
        
End Sub
 
Upvote 0
Ok, how about
VBA Code:
Sub jordanburch()
   Range("C8:C17").SpecialCells(xlBlanks).EntireRow.Value = ""
End Sub
 
Upvote 0
Thanks you guys! they both worked perfectly. I appreciate your help. I really need to learn how to do these easy ones on my own.

J
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Ok, how about
VBA Code:
Sub jordanburch()
Range("C8:C17").SpecialCells(xlBlanks).EntireRow.Value = ""
End Sub
Well, that was easier than I thought! I was trying to work out how to get from the SpecialCells to the entire rows, and making it much harder than it needed to be!
Soemtimes, we overlook the obvious!
 
Upvote 0
well at least you know how to complete it! much more ahead of myself. I can modify little things here and there but its difficult for me to write this from scratch!
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,854
Members
449,051
Latest member
excelquestion515

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