Originally Posted by
PatNecom
With my current code AR column is filled with text "
=IF(X2=""Disposal"",IF(Y2=""Invoice"",X2,""Liquidation""),Y2)"
rather than giving the result of the formula
The AR column cannot be formatted as text. If it's formatted in this way, you'll get the formula content, not the result.
Originally Posted by
PatNecom
I wanted to value to be placed from AR2 until the last row with data (and for this I used column B as reference as it is one of the columns that will always have data (no empty cells)).
The code is supposed to be OK. But until at least cell B3 is full. If the cells below B2 are empty, then Range("B2").End(xlDown).Row will indicate the last row in the worksheet (B1048574). Therefore, it is better to use the search from below. After the patch, the code might look like this
Sub Test1()
Dim Rng As Range
Columns("AR:AR").Insert
Set Rng = Range("AR2:AR" & Cells(Rows.Count, "B").End(xlUp).Row)
If Rng.Rows.Count > 1 Then
Rng.Formula = "=IF(X2=""Disposal"",IF(Y2=""Invoice"",X2,""Liquidation""),Y2)"
End If
End Sub
Artik