Hi all
I have been trying to figure out how to write a macro on the following task for the past 6 hours and end up seeking assistance
in my usual place; Woody.I have a database in sheet 1 and I need to group this data under Name and Symbol Code, after which,
I need to sum the Total Unit and Total Amount for each change in Name and Symbol Code.
I can only wrote up to for each change in Symbol Code but not both including Name and Symbol Code. Pls have a look
at the below code and the attached and advise how to tweak the marco to perform the result that I am looking for.
Sheet 2 shows the result of the codes below
Sub SortAndGroupTotal()
Dim i As Long
Dim lastrow As Long
Dim saverow As Long
‘Initialize
saverow = 1
‘Get last row, Col A
lastrow = Range(“A65536”).End(xlUp).Row
‘Select & sort Col A to K
Range(“A2:K” & lastrow).Select
Selection.Sort Key1:=Range(“E2”), Order1:=xlAscending, Key2:=Range( _
“A2”), Order2:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal
‘Check for duplicates in Col A
For i = 2 To lastrow
If Cells(i, 1) Cells(i + 1, 1) Then
Cells(i, 9) = “=Sum(H” & saverow & “:H” & i & “)”
saverow = i + 1
End If
Next i
End Sub
TIA
Regards, francis