Adding a = sum formula to code

Steve001

Board Regular
Joined
Apr 13, 2017
Messages
62
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
Hi all

Bit stuck, want to look at my sheet and add a = SUM calculation I am using last command to find the last row

last = Cells(Rows.count, "F").End(xlUp).Row

so how do I put into my sheet ?

=SUM(G2:last row)

hope this makes sense

ps please put comments on the example as I am still finding my way round vba

Steve
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Try:
Code:
last = Cells(Rows.Count, 6).End(xlUp).Row
Msgbox last
Msgbox "G2"
Msgbox "G2:G"
Msgbox "G2:G" & last
Cells(1, 1).Formula = "=SUM(G2:G" & last)"
Then edit as required.

NB: A1 = row 1, column 1, F7 = row 7, column 6 so Cells(1, 1) = Range("A1"), Cells(7, 6) = Range("F7") etc
 
Upvote 0

Forum statistics

Threads
1,214,405
Messages
6,119,315
Members
448,886
Latest member
GBCTeacher

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