View Single Post
 
Old 10-08-2020, 08:58 PM
leeqiang leeqiang is offline Windows 10 Office 2019
Advanced Beginner
 
Join Date: Aug 2020
Posts: 53
leeqiang is on a distinguished road
Default

Quote:
Originally Posted by Purfleet View Post
i know why you merge cells, but they will only cause problems - it is far better to 'center accross selection'

Code:
Sub SumCols()

Dim LR As Integer 'change to Long if your rows can go over 32000

LR = Cells(Rows.Count, 1).End(xlUp).Row ' Last row calculated on the first column

Range("d" & LR + 1) = "=Sum(d2:d" & LR & ")"
Range("f" & LR + 1) = "=Sum(f2:f" & LR & ")"
Range("g" & LR + 1) = "=Sum(g2:g" & LR & ")"


End Sub
1 - This will sum the 3 columns (you sure you want to sum the price?)
2 - The last row is based on column 1, so will always sum to the last row unless you put something like Total in row 13 then the previous total would be included in the next sum
3 - Can you clarify this part?

thx very much,the result is very good!


1.and sum the freight,the date of last columns.
2.can add a cells name is "total",automating add at the same row of sum ,such as column A of the sum row
3.clarify
Reply With Quote