Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-07-2020, 04:20 AM
Purfleet Purfleet is offline I use an array to traverse the monthly worksheet summaries in the workbook, why the display types do Windows 10 I use an array to traverse the monthly worksheet summaries in the workbook, why the display types do Office 2019
Expert
 
Join Date: Jun 2020
Location: Essex
Posts: 345
Purfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to behold
Default

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
Reply With Quote
  #2  
Old 10-07-2020, 08:20 PM
leeqiang leeqiang is offline I use an array to traverse the monthly worksheet summaries in the workbook, why the display types do Windows 10 I use an array to traverse the monthly worksheet summaries in the workbook, why the display types do Office 2019
Advanced Beginner
I use an array to traverse the monthly worksheet summaries in the workbook, why the display types do
 
Join Date: Aug 2020
Posts: 49
leeqiang is on a distinguished road
Default

Quote:
Originally Posted by Purfleet View Post
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



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!
Reply With Quote
Reply



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

Other Forums: Access Forums

All times are GMT -7. The time now is 12:26 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft