Jose M.
Jose M.

Reputation: 2350

Clear contents of column if condition is met

I am trying to write a procedure that checks if rows in column BO are empty, if they are, then clear the contents of the same row in column BQ. For example:

enter image description here

In this example everything after Test 3 in Column BQ should be blank. I wrote the following:

With calcCalculations

For Each rng In Columns("BO").SpecialCells(xlBlanks)
    rng.Offset(, 3).Value = ""

Next

End With

But is not working for me. the procedure runs without bugs but nothing happens. Also the data on column BQ is calculated. In other words, the 0 is a result of a formula on column BQ.

Thanks

Upvotes: 0

Views: 737

Answers (1)

johnwait
johnwait

Reputation: 1134

Why don't you just wrap your current formula for the BQ column in an IF() clause, like:

=IF(BO1<>"";{current_formula};"")

That means: If adjacent cell in column BO is empty, also show an empty string (otherwise show the formula's result).

If you actually want nothing to appear when the value in column BQ is zero (rather than depending on the text in column BO), you have to use something like:

=IF({current_formula}<>0;{current_formula};"")

Upvotes: 1

Related Questions