Clear Cell Contents based on Cell Value

SDave

Board Regular
Joined
Aug 12, 2008
Messages
152
Office Version
  1. 365
Platform
  1. MacOS
Afternoon all,

I'm hoping someone can help me.

I need to be able to clear the contents of cells in column C, D, E, H if the value of column Q equals HELLO for arguments sake.

Clearing the contents of an entire row is not a problem, however when it comes to resizing rows I seem to come unstuck.

Related thread: http://www.mrexcel.com/forum/showthread.php?t=476993

Any help would be appreciated.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hello

I may have missed the point, and grossly oversimplified things.
So please try the below on a COPY of your data.

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> SDave()<br><SPAN style="color:#00007F">Set</SPAN> sh = Sheets("Successors_for_Roles")<br>  lr = sh.Rows(sh.UsedRange.Rows.Count).Row<br>  Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN><br>    <SPAN style="color:#00007F">For</SPAN> i = 1 <SPAN style="color:#00007F">To</SPAN> lr<br>      <SPAN style="color:#00007F">If</SPAN> Cells(i, "Q") = "HELLO" <SPAN style="color:#00007F">Then</SPAN><br>        sh.Cells(i, "C").Resize(, 3).ClearContents<br>        sh.Cells(i, "H").ClearContents<br>      <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>    <SPAN style="color:#00007F">Next</SPAN> i<br>  Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0
Thanks Brian, your a star. Much appreciated. That's exactly what I was after.
 
Upvote 0
Hi,

Can you please let me know how i can make it dynamic. I mean it should check each row one and by one with the range of 1-20000 rows automatically.

its very urgent...Many thanks in advance

Thanks
Zenta


Hello

I may have missed the point, and grossly oversimplified things.
So please try the below on a COPY of your data.

Sub SDave()
Set sh = Sheets("Successors_for_Roles")
**lr = sh.Rows(sh.UsedRange.Rows.Count).Row
**Application.ScreenUpdating = False
****For i = 1 To lr
******If Cells(i, "Q") = "HELLO" Then
********sh.Cells(i, "C").Resize(, 3).ClearContents
********sh.Cells(i, "H").ClearContents
******End If
****Next i
**Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,624
Messages
6,120,591
Members
448,973
Latest member
ksonnia

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