Hi,
I'm trying to add a formula into any cells in col A of a sheet where col B has data. I need the code to:
Look for last row in col B
If col B has data but A is empty
col A cell value = "Formula"
So in the below snip, the cells highlighted in yellow would be the ones where the formula is added.
They will be the last rows in each column, if it makes things easier. So basically the code would make both columns the same length by filling col A with the formula.
I did try this code but it only works if text is typed into cells, it doesn't work if multiple cells are pasted into col B.
That was more difficult to explain than I thought, so I hope it makes sense.
I'm trying to add a formula into any cells in col A of a sheet where col B has data. I need the code to:
Look for last row in col B
If col B has data but A is empty
col A cell value = "Formula"
So in the below snip, the cells highlighted in yellow would be the ones where the formula is added.
They will be the last rows in each column, if it makes things easier. So basically the code would make both columns the same length by filling col A with the formula.
I did try this code but it only works if text is typed into cells, it doesn't work if multiple cells are pasted into col B.
VBA Code:
If target.Column <> 2 Or target.Cells.Count > 1 Then Exit Sub
If target.Offset(0, -1) = "" Then
target.Offset(0, -1) = “TheFormula”
End If
That was more difficult to explain than I thought, so I hope it makes sense.