Hi guys, I need to clear cells in column A depends on what is in cell B, (for example if in B20 is "Director" I have to clear the cell A20), do you know what kind of VBA formula can I use to do this?
Thank you so much, in advance
Hi guys, I need to clear cells in column A depends on what is in cell B, (for example if in B20 is "Director" I have to clear the cell A20), do you know what kind of VBA formula can I use to do this?
Thank you so much, in advance
Thanks for the Like. Did this solve your problem?
Yes I do, now I have another problem
I need to clear all the cells that are bellow a headline (PERSONE NEL CAB), this headline is not always in the same row and is in merged columns so I do not know if there is a way to clear all the cells below it (starting from 2 rows below that headline ).
You should always avoid MergedCells, Is PERSONE NEL CAB the header for the column? A small example workbook might make it easier to see what you mean
Here you can see (PERSONE COINVOLTE DEL CAB) in row 19 but in other files can be in cell 27, 30, 32, 15 etc
See if this works, it does on the example.
Sub ClearRange()
Const str As String = "PERSONE COINVOLTE DEL CAB"
Dim rCl As Range, rRng As Range
Dim Rws As Integer
Set rCl = ActiveSheet.UsedRange.Find(str, LookIn:=xlValues, lookat:=xlWhole)
Set rCl = rCl.Offset(2)
Rws = Range(rCl, rCl.Offset(, 1).End(xlDown)).Rows.Count
Set rRng = rCl.Resize(Rws, 3)
rRng.ClearContents
End Sub
Display More
It works perfectly, thank you so much
Pleased to help
Don’t have an account yet? Register yourself now and be a part of our community!