I have this code which I modify for each scenario in any given workbook:
************************************************************
Sub Sort_Sheet_NotesFromPrograms()
'
ActiveSheet.Unprotect 'place at the beginning of the code
Application.Goto Reference:="R1C1"
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
ActiveSheet.Protect ' place at end of code
Range("A2").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
End Sub
************************************************************
The difficulty is that if there aren't at least two rows with data, I get an
error message. For me, that's fine. I know the reason behind the error box
so no worries. But I'd like to have better code so I can share these
workbooks knowing that even blank sheets will work flawlessly and the users
won't get flustered by these error boxes popping up.
Is there a way to incorporate something that will help in those cases where
there is not yet anything to sort?
TIA. Much appreciated. You guys, as always, are the best! :oD
Bookmarks