Question

Im trying to Make a macro which will take the fomulas in cells B358 to B362 and autofill these rows to the last column used in row 2.

Im pretty new at VBA and completely selftaught by searching forums like this but unfortunately im not finding my solution.

Please help me

Edit:

If you need to see some code, i can give you a very basic example

Sub Macro1()

    Range("B358:B362").Select
    Selection.AutoFill Destination:=Range("B358:AHQ362"), Type:=xlFillDefault
    Range("B358:AHQ362").Select
End Sub

In this example i would need the AutoFill destination to be (B358:"insert last column used in row 2 here"362)

Était-ce utile?

La solution

That is proposed dynamic solution in your situation:

Sub Macro1()


Dim lastCol As Long
lastCol = Cells(2, Columns.Count).End(xlToLeft).Column

 Range("B358:B362").AutoFill Destination:=Range(Range("B358"), Cells(362, lastCol)), Type:=xlFillDefault

End Sub
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top