S
StargateFanFromWork
Was hoping to get best approach to this situation below.
When the sheet has data in it, the macro below works perfectly:
*********************************************
Sub SortByDate()
'
'
Application.Goto Reference:="R1C2"
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Key2:=Range("D2")
_
, Order2:=xlAscending, Key3:=Range("E2"), Order3:=xlAscending,
Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom
Range("B2").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
End Sub
*********************************************
When there is no data, I obviously get an error code. The code says:
"Run-time error '1004':
Application-defined or object-defined error"
How can I have the sheet return a box saying, "There is no data to sort" or
something instead of that error code. Due to the great help here, I now
know how to write up a message box (yeay!) so that part is not so hard. But
how would I handle the other, pls?
Thanks!
When the sheet has data in it, the macro below works perfectly:
*********************************************
Sub SortByDate()
'
'
Application.Goto Reference:="R1C2"
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Key2:=Range("D2")
_
, Order2:=xlAscending, Key3:=Range("E2"), Order3:=xlAscending,
Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom
Range("B2").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
End Sub
*********************************************
When there is no data, I obviously get an error code. The code says:
"Run-time error '1004':
Application-defined or object-defined error"
How can I have the sheet return a box saying, "There is no data to sort" or
something instead of that error code. Due to the great help here, I now
know how to write up a message box (yeay!) so that part is not so hard. But
how would I handle the other, pls?
Thanks!