nandobarreto
New Member
- Joined
- Jan 22, 2018
- Messages
- 6
- Office Version
- 365
- Platform
- Windows
Hi,
I have a Table where I color some cells and sometimes I need to sort them by color.
To do so, I go on the sort menu.
I would like to do this using a VBA macro
I "wrote" this, but isnt working,
I tried too:
No lucky!
Any help?
Thanks
I have a Table where I color some cells and sometimes I need to sort them by color.
To do so, I go on the sort menu.
I would like to do this using a VBA macro
I "wrote" this, but isnt working,
VBA Code:
Sub Macro2()
'
Dim rng As String
rng = Selection.Address
ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear
ActiveWorkbook.ActiveSheet.Sort.SortFields.Add2 Key:= _
Range(rng), SortOn:=xlSortOnCellColor, Order:=xlDescending, _
DataOption:=xlSortNormal
With ActiveWorkbook.ActiveSheet.Sort
.SetRange Range(rng)
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
I tried too:
VBA Code:
Dim rng As Range
Set rng = Range(Selection.Address)
No lucky!
Any help?
Thanks