Hi everyone!
I have been trying to create a macro that does the following:
- Sort current selection according to the cell color in row 1 (either white or yellow)
- Sort current selection according to the values in row 3 (ascending)
- Delete columns (only in the selection) where the color in row 1 is not yellow (the one used in conditional formatting)
- Shift cells up
What I have so far is:
Sub TITLE()
'
' TITLE Macro
'
' Keyboard Shortcut: Ctrl+Shift+B
'
Dim myRange As Range
Set myRange = Selection
ActiveWorkbook.Worksheets(ActiveSheet.Name).Sort.SortFields. _
Clear
ActiveWorkbook.Worksheets(ActiveSheet.Name).Sort.SortFields. _
Add Key:=sortRange.Resize(1, sortRange.Columns.Count), SortOn:=xlSortOnCellColor, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets(ActiveSheet.Name).Sort
.SetRange sortRange
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
I am, however, lost on how to sort in row 3 (I have read of the 'offset' function but don't really know how to implement that) as well as on how to delete the columns i don't want...
Any help would be greatly appreciated!
Many thanks in advance
Bookmarks