![]() |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
![]()
the file:
sum.xlsm How to use an array to traverse the worksheet and summarize them separately? Why does a dialog box that does not match the type pop up after running the code? Summarize the number of pieces, quantity, price, and freight in each monthly table. code show as below: Option Explicit Sub sumallshs() Dim i, j, p, q Dim arr, brr Dim sh As Worksheet For Each sh In Worksheets If Trim(sh.Name) Like "*m" Then p = sh.Cells.Rows.Count q = sh.Cells(p, 1).End(xlUp).Row arr = sh.Range("a2:h" & q) brr = sh.[a2].Resize(UBound(arr) + 1, UBound(arr, 2) + 1) If q >= 3 Then For j = 4 To UBound(brr) For i = 1 To UBound(brr) - 1 brr(UBound(brr), 3) = "total" brr(UBound(brr), j) = brr(UBound(brr), j) + brr(i, j) Next i Next j sh.[a2].Resize(UBound(brr), UBound(brr, 2)) = brr End If End If Next sh end sub After running the code, the following dialog box pops up 20201007075828.jpg |
|
![]() |
||||
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 |