paulyankson
New Member
- Joined
- Sep 3, 2016
- Messages
- 6
Hi,
A question for the assembled Brains Trust:
- I have a personal spreadsheet
- let's say the range is A1:E200
- the cells A1:E100 have a yellow background that I have manually coloured in
- the cells A101:E200 don't have any coloured background
- all cells have data in them so I can't use a command to just go to the last populated cell in the column
- I need a macro command to move down to the last cell in the column that is coloured yellow
- eg: move down to cell A100 in the column and stop there
- a couple of days later one extra row will be highlighted with a yellow background
- eg: A1:E101 now
- so I'll need the cursor to utomatically move to the latest yellow cell that is coloured yellow
- eg: move down to cell A101 in the column and stop there
I'm using this macro at the moment ..... but it obviously takes me to the last empty cell in the entire sheet, ignoring the coloured background.
Thanks for any pointers!
Paul
A question for the assembled Brains Trust:
- I have a personal spreadsheet
- let's say the range is A1:E200
- the cells A1:E100 have a yellow background that I have manually coloured in
- the cells A101:E200 don't have any coloured background
- all cells have data in them so I can't use a command to just go to the last populated cell in the column
- I need a macro command to move down to the last cell in the column that is coloured yellow
- eg: move down to cell A100 in the column and stop there
- a couple of days later one extra row will be highlighted with a yellow background
- eg: A1:E101 now
- so I'll need the cursor to utomatically move to the latest yellow cell that is coloured yellow
- eg: move down to cell A101 in the column and stop there
I'm using this macro at the moment ..... but it obviously takes me to the last empty cell in the entire sheet, ignoring the coloured background.
Thanks for any pointers!
Paul
VBA Code:
Sub Macro1()
'
' Macro1 Macro
' sort au page, first by K column descending, then by E column ascending. then move down to first vacant spot in A column.
'
'
Range("A8:A20").Select
Range(Selection, Selection.End(xlDown)).Select
Range("A8:B3511").Select
Range(Selection, Selection.End(xlToRight)).Select
Range("A8:K3511").Select
ActiveWorkbook.Worksheets("au").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("au").Sort.SortFields.Add Key:=Range("K8:K3511"), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("au").Sort.SortFields.Add Key:=Range("E8:E3511"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("au").Sort
.SetRange Range("A8:K3511")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A8:A8").Select
Range(Selection, Selection.End(xlDown)).Select
Range("A8").Select
Selection.End(xlDown).Select
End Sub
Last edited by a moderator: