Related:
- How add the rows with the same value in a col
- How to add at the rate in laptop - Guide
- 2007 microsoft office add-in microsoft save as pdf or xps - Download - Other
- How to add subtitles in kmplayer - Guide
- How to add photo in word resume - Guide
- How to add a checkmark in word - Guide
2 responses
venkat1926
Posts
1863
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
811
Oct 14, 2010 at 07:00 AM
Oct 14, 2010 at 07:00 AM
the first sheet is called "sheet1"
the second sheet is called "summary"
copy all the macros/function in the standard module
BUT RUN ONLY "A_overall_macro"
prefix A is given so that this macro will be first in the list.
the macros are dynamic that is you can have as many rows or columns.
TRY THIS ON YOUR TRUNCATED DATA AS GIVEN IN THE POST.
post your comments
the second sheet is called "summary"
copy all the macros/function in the standard module
BUT RUN ONLY "A_overall_macro"
prefix A is given so that this macro will be first in the list.
the macros are dynamic that is you can have as many rows or columns.
TRY THIS ON YOUR TRUNCATED DATA AS GIVEN IN THE POST.
Dim r As Range, r1 As Range, c1 As Range, x As String, s As Double
Dim j As Long, k As Long
Dim m As Long, n As Long, rfilt As Range, ssum As Double
Sub idname()
With Worksheets("sheet1")
Set r = Range(.Range("A1"), .Range("A1").End(xlDown).Offset(0, 1))
r.AdvancedFilter action:=xlFilterCopy, copytorange:=Worksheets("summary").Range("A1"), _
unique:=True
End With
End Sub
Function Sum_Visible_Cells(Cells_To_Sum As Object) 'reference https://support.microsoft.com/en-us/help/150363 Dim cell As Range, total As Double Application.Volatile For Each cell In Cells_To_Sum If cell.Rows.Hidden = False Then If cell.Columns.Hidden = False Then total = total + cell.Value End If End If Next Sum_Visible_Cells = total End Function
Sub summingup()
With Worksheets("sheet1")
j = .Range("A1").End(xlToRight).Column
m = Worksheets("summary").Range("A1").End(xlDown).Row
For k = 3 To j
For n = 2 To m
With Worksheets("summary")
'msgbox Cells(n, 2).Address
x = .Cells(n, 2)
'msgbox x
End With
Set r = .Range("A1").CurrentRegion
'msgbox r.Address
r.Cells.AutoFilter field:=2, Criteria1:=x
ssum = Sum_Visible_Cells(Range(.Cells(2, k), .Cells(2, k).End(xlDown)))
'msgbox ssum
With Worksheets("summary")
.Cells(n, k) = ssum
End With
r.AutoFilter
Next n
Next k
End With
End Sub
Sub A_overall_macro()
Worksheets("summary").Cells.Clear
idname
summingup
End Sub
post your comments