asyamonique
Well-known Member
- Joined
- Jan 29, 2008
- Messages
- 1,280
- Office Version
- 2013
- Platform
- Windows
Hello,
Is it possible to add to below code that I can also sort the datas from Largest to Smallest on the ListBox2 ?
Many Thanks
Is it possible to add to below code that I can also sort the datas from Largest to Smallest on the ListBox2 ?
Many Thanks
VBA Code:
Private Sub CommandButton12_Click()
Application.ScreenUpdating = False
On Error Resume Next
Dim J As Long, Dic As Object, rng As Range, Ac As Integer
Set Dic = CreateObject("scripting.dictionary")
Dic.CompareMode = vbTextCompare
Set rng = Sheets("overtimelist").Range("A:A").CurrentRegion.Resize(, 6)
ReDim nRay(1 To rng.Count, 1 To 6)
For J = 1 To rng.Count
If Not Dic.Exists(rng(J, 1).Value) Then
Dic.Add rng(J, 1).Value, rng(J, 5).Text
Else
Dic(rng(J, 1).Value) = Dic(rng(J, 1).Value) + rng(J, 5).Value
End If
For Ac = 1 To 6
nRay(J, Ac) = rng(J, Ac).Text
Next Ac
Next J
With ListBox1
.ColumnCount = 6
.ColumnWidths = "140;100;90;100;70;0"
.list = nRay
End With
With ListBox2
.ColumnCount = 2
.ColumnWidths = "150;80"
.list = Application.Transpose(Array(Dic.keys, Dic.Items))
End With
Application.ScreenUpdating = True
End Sub