VBA Drag down cell content to end of data

Kra

Board Regular
Joined
Jul 4, 2022
Messages
160
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I have some troubles with macro. I need to drag down formulas and fixed values from range O3:BB8 to the end of data in column N.

I tried to do it this way, but it's not working:
VBA Code:
Public Function GetLastRow(Optional Col As Integer = 1, Optional Sheet As Excel.Worksheet)
    
    If Sheet Is Nothing Then
        Set Sheet = Application.ActiveSheet
        GetLastRow -Sheet.Cells(Sheet.Rows.Count, Col).End(xlUp).Row
    End If
 End Function

Sub DragFormulas()

 Dim LastRow As Long
 
    LastRow = GetLastRow(1, Worksheets("SUM"))
    
    Worksheets("SUM").Range("O3:BB8").AutoFill
     Destination:=Worksheets("SUM").Range("O3:BB" & LastRow), _
     Type:=xlFillDefault
    
End Sub

Any ideas how to achieve it?
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,215,973
Messages
6,128,040
Members
449,414
Latest member
sameri

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