Copy & paste formula down a column

C

ChipButtyMan

Hi,
I have a simple formula like;

=PattMatch(A2,MainMap!$A$12:$F$15,MainMap!$H$11:$I$17,MainMap!$A$19:$B
$24)

I have a command button to enter it into Range("C2")

How do I copy & paste it into all rows below?

Thank you for your help.
 
M

Mike H

Hi,

I suspect you don't really mean all rows so change the autifill destination
to the last row you want.

Range("C2").Formula =
"=PattMatch(A2,MainMap!$A$12:$F$15,MainMap!$H$11:$I$17,MainMap!$A$19:$B$24)"
Range("C2").AutoFill Destination:=Range("C2:C31")

Mike
 
G

Gord Dibben

Sub Auto_Fill()
Dim Lrow As Long
With ActiveSheet
Lrow = .Range("B" & Rows.Count).End(xlUp).Row
.Range("C2:C" & Lrow).FillDown
End With
End Sub

You could use one macro to add the formula to C2 then copy down.

Sub Auto_Fill()
Dim Lrow As Long
With ActiveSheet
.Range("C2").Formula = "=PattMatch(A2,MainMap!$A$12:$F$15," & _
"MainMap!$H$11:$I$17,MainMap!$A$19:$B$24)"
Lrow = .Range("B" & Rows.Count).End(xlUp).Row
.Range("C2:C" & Lrow).FillDown
End With
End Sub



Gord Dibben MS Excel MVP
 
Top