Is possible to sum a column and put the value below last row of the column?

jaik22

Board Regular
Joined
Sep 23, 2016
Messages
102
Is possible to sum column's value and put it into below last of the row?
I know how to put data as last row of value, but can't figure it out how to put a value below last column.

Thank you!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
jaik22,

I would like more information. Please see the Forum Use Guidelines in the following link:

http://www.mrexcel.com/forum/board-announcements/127080-guidelines-forum-use.html


See reply #2 at the next link, if you want to show small screenshots, of the raw data, and, what the results should look like.

http://www.mrexcel.com/forum/about-board/508133-attachments.html#post2507729


Or, you can post your workbook/worksheets to the following free site (sensitive data changed), mark the workbook for sharing, and, provide us with a link to your workbook:

https://dropbox.com
 
Upvote 0
Here you go:
Code:
Sub jaik22()

Dim lrow As Long
Dim myclm As Integer

myclm = 1 'Change to the column you would like to evaluate
lrow = Cells(Rows.Count, myclm).End(xlUp).Row 'Calculates last row

Cells(lrow + 1, myclm) = WorksheetFunction.Sum(Range(Cells(1, myclm), Cells(lrow, myclm))) 'Sums the column you choose and places it in the last row + 1

End Sub

This is currently looking at column A, if you want to change the column update this line of code to the column number:
Code:
myclm = 1 'Change to the column you would like to evaluate

Sincerely,
Max
 
Upvote 0
Code:
Column I
[TABLE="width: 64"]
 <colgroup><col width="64" style="width:48pt"> </colgroup><tbody>[TR]
  [TD="width: 64, align: right"]-96[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-96[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-96[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-192[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-72[/TD]
 [/TR]
 [TR]
  [TD="align: right"]69.17647[/TD]
 [/TR]
 [TR]
  [TD="align: right"]138.3529[/TD]
 [/TR]
 [TR]
  [TD="align: right"]240[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-48[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-48[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-24[/TD]
 [/TR]
 [TR]
  [TD="align: right"]1152[/TD]
 [/TR]
 [TR]
  [TD="align: right"]48[/TD]
 [/TR]
 [TR]
  [TD="align: right"]276.7059[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-48[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-48[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-48[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-48[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-96[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-48[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-48[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-48[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-24[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-24[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-72[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-48[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-72[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-72[/TD]
 [/TR]
 [TR]
  [TD="align: right"]456[/TD]
 [/TR]
 [TR]
  [TD="align: right"]120[/TD]
 [/TR]
 [TR]
  [TD="align: right"]172.9412[/TD]
 [/TR]
 [TR]
  [TD="align: right"]172.9412[/TD]
 [/TR]
 [TR]
  [TD="align: right"]144[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-24[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-360[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-48[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-72[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-48[/TD]
 [/TR]
 [TR]
  [TD="align: right"]-120[/TD]
 [/TR]
 [TR]
  [TD="align: right"]216[/TD]
 [/TR]
 [TR]
  [TD="align: right"]69.17647[/TD]
 [/TR]
 [TR]
  [TD="align: right"]600[/TD]
 [/TR]
 [TR]
  [TD="align: right"]48[/TD]
 [/TR]
 [TR]
  [TD="align: right"]24[/TD]
 [/TR]
 [TR]
  [TD="align: right"]241.8706[/TD]
 [/TR]
 [TR]
  [TD="align: right"]241.8706[/TD]
 [/TR]
 [TR]
  [TD="align: right"]2343.035[/TD]
[/TR]
</tbody>[/TABLE]
Sorry for the vague information.
The last row is the sum of all numbers in the column. I would like to have vba code for like that. Is it possible?

Thank you
 
Last edited:
Upvote 0
My code should accomplish that. Did it not work?
 
Upvote 0
If you are looking at column I, try this:
Code:
Sub jaik22()

Dim lrow As Long
Dim myclm As Integer

myclm = 9 'Change to the column you would like to evaluate
lrow = Cells(Rows.Count, myclm).End(xlUp).Row 'Calculates last row

Cells(lrow + 1, myclm) = WorksheetFunction.Sum(Range(Cells(1, myclm), Cells(lrow, myclm))) 'Sums the column you choose and places it in the last row + 1

End Sub
 
Upvote 0
jaik22,

Here is a macro solution for you to consider, based on your flat text display, that will put a Sum formula in Column I, in the last used row +1, in the active worksheet.

Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

Code:
Sub SumColumnI()
' hiker95, 10/14/2016, ME970497
Dim lr As Long
Application.ScreenUpdating = False
With ActiveSheet
  lr = .Cells(Rows.Count, "I").End(xlUp).Row
  With .Range("I" & lr + 1)
    .Formula = "=Sum(I1" & ":" & "I" & lr & ")"
    .NumberFormat = "#,##0.00000"
  End With
  .Columns("I").AutoFit
End With
Application.ScreenUpdating = True
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm, and, answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.

Then run the SumColumnI macro.
 
Upvote 0
jaik22,

Thanks for the feedback.

You are very welcome. Glad we could help.

And, come back anytime.
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,279
Members
449,075
Latest member
staticfluids

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