Autosum using the last row from another column vba

jufglanville

New Member
Joined
Sep 11, 2017
Messages
23
Hi all, I'm looking to place an autosum function via vba into my worksheet. I am wanting the values to select all cells from F3 down to the last row of data that appears in the A column. For example if the last cell containing data in column A was A6 then I would want the autosum function to work on cells F3:F6.

Thanks in advance
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
And ... which autosum function do you want to apply to those cells and where do you want the result placed?
 
Upvote 0
Hi Joe, I'm after SUM and the reason I want to go by the last row of A is that the column lengths vary frequently and column A is the only column that contains no breaks between data. The answer will therefore vary it's location and I'm hoping to adapt the following to make it work for me in some way.
Code:
 Range("A1").Select    Selection.End(xlDown).Select
    
    ActiveCell.Offset(2, 5).Value =
 
Upvote 0
Assuming the row number of the last filled cell in col A is always at least as large as the last filled cell in col F, this should work:
Code:
Sub SumIt()
Range("F" & Cells(Rows.Count, "A").End(xlUp).Row + 1).Value = _
    WorksheetFunction.Sum(Range("F3:F" & Cells(Rows.Count, "A").End(xlUp).Row))
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,141
Members
453,021
Latest member
Justyna P

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