I would like to add a formula to a cell and then autofill all the way down to lr.
Currently I'm using:
lr = Cells.Find("*", Cells(1,1), xlFormulas, xlPart, xlByRows, xlPrevious, False).Row
Dim header as range
Set header = range("A1:AA1")
' The Group column has empty cells. It just has header as Group.
' This code finds the column header Group for me and puts formula in 1 cell under it. This part is fine.
header.Find("Group").Offset(1,0).FormulaR1C1 = "=left(rc[-1],4)"
' Now I need to autofill that formula all the way down to lr
' I'm currently using this
header.Find("Group").Offset(1,0).Autofill Range ("B2:B" & lr)
I do not want to use "B2:B" as Group column could be anywhere else. I'd like it to be more dynamic.
Is there a way to change "B2:B" so instead it finds Group header and autofills 1 cell down from it all the way down to lr?