VBA Autofill Formula to last row w data

Littlemalky

Board Regular
Joined
Jan 14, 2011
Messages
223
Hey, so I have this line of code that seems like it should work, I don't get any kind of error when I run the macro; however, when I check my file the only part of it that worked was the copying and pasting the formula into the single cell. Even though I have the autofill language in there, it doesn't seem to be applying it to the column. Here's what I have:
Code:
Range("D2").Copy _
        Destination:=Workbooks("Fulfillment " & Format(Date, "yyyymmdd") & " - Domestic" & ".xlsx").Worksheets("detail w add").Range("S2")
    With Range("S2")
        .AutoFill Destination:=Range("S2", Cells(Cells(Rows.Count, 20).End(xlUp).Row, 19))
    End With
I just need it to autofill down to the last row with data in it. I have data in columns A:V if that's relevant, but I only want to autofill column "S".
 
Code:
Dim wb As Workbook
Dim ws As Worksheet
Set wb = Workbooks("Fulfillment " & Format(Date, "yyyymmdd") & " - Domestic" & ".xlsx")
Set ws = wb.Worksheets("detail w add")
Range("D2").Copy _
        Destination:=ws.Range("S2")
With ws
    .Range("S2").AutoFill Destination:=.Range(.Cells(2, 19), .Cells([B][COLOR=red].[/COLOR][/B]Cells(Rows.Count, 20).End(xlUp).row, 19))
End With

Forgot another period in the Destination:= statement.
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
What if, instead of copying the formula from the other workbook and pasting it to this one, I just insert the formula =NETWORKDAYS(Q2,R2)-1, which should be static, and fill it down. What would that look like?
 
Upvote 0

Forum statistics

Threads
1,225,157
Messages
6,183,247
Members
453,152
Latest member
ChrisMd

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top