I have the following Excel table:
I would like to delete all the lines where "HFO", for example, is written (rows 16-18 in this case).
Is there any way to do it or to identify how many rows are part of a merged cell?
I have seen Delete rows with merged cells. It doesn't work for me because rows 10-15 also have merged cells and I don't want to delete them.
MergeArea
returns a Range object referenced to all merged cells. Because you need to delete the rows, then add EntireRow
object:
Dim rng As Range
For Each rng In Range("C16:C24")
If rng.Value = "HFO" Then rng.MergeArea.EntireRow.Delete
Next rng
Output after code:
Notice we deleted only those rows with merged cells and value "HFO"