Hi guys,

new to the forum, so apologies if this is already covered and I didnt find it.

I want to autofill down a column, based on the presence of data in another column.

For example, this is the data column that exists:

a
a
b
b

And I want to fill down in a second column an if statement:

=if(a1="a","1","2")

However, for various reasons related to the usage of this workbook, I cannot rely on the formula remaining present in the source cell of an autofill script.

Currently, I have this:

Public Sub autofill()
Worksheets("Sheet4").Range("B1").autofill Destination:=Range("B1:B" & Cells(Rows.Count, "A").End(xlUp).Row)
End Sub

What I need is to replace "Worksheets("Sheet4").Range("B1")" with the formula itself.

Anyone have a solution here?

thanks!

Wiggin