![]() |
|
|||||||
|
|
|
Thread Tools | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Leeqiang
This is why you need to ask the full question at the begining - in your orginal post you said the 15th row and Column K, so i assumed the grid was static. If you want to work out varible rows and columns try this - there might be neater or nicer ways but you dont need a loop to sum Sub sumtheall() Dim LR As Integer Dim LC As Variant Dim LRSum As Integer Dim LCSum As Variant 'Find last row LR = Cells(Rows.Count, 1).End(xlUp).Row + 1 LRSum = LR - 1 'Find last column LC = Cells(1, Columns.Count).End(xlToLeft).Column + 1 'Change column to Letter LCSum = Chr(LC + 64 - 1) LC = Chr(LC + 64) 'Input Sum Range("a" & LR & ":" & LC & LR) = "=sum(a1:a" & LRSum & ")" Range(LC & "1:" & LC & LR) = "=Sum(a1:" & LCSum & "1)" End Sub |
|
#2
|
|||
|
|||
|
Quote:
Thank you very much for your help! run the code have same wrong results in the photo as follows: 20201008111050.png 1.the result don't sum the columns of price, quantity,freight 2.when click the button many times,the result produce under the result before. I want to produce the result under the data range whatever how many times clicked the button. 3.advanced,how to use the code to get rid of each worksheets's name like *m in this workbook thx again! |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How can I copy a worksheet and paste values to another new workbook ? | DBenz | Excel | 1 | 01-26-2019 07:03 AM |
| Sharing a Workbook that contains array formula link to other workbook | Ahmad.rage22@gmail.com | Excel | 0 | 03-12-2018 10:15 PM |
| Outlook 2016 calendar monthly display | Herbert | Outlook | 0 | 09-22-2017 04:41 AM |
| How do I populate Worksheets using information entirely from another Worksheet in the same Workbook? | BrieDanielle | Excel | 1 | 06-18-2016 10:50 AM |
| Counting unique visitors by ward, counting monthly visits by status, editing existing workbook | JaxV | Excel | 9 | 11-14-2014 12:25 AM |