Macro question

T

Terry Bennett

I'm sure this is a very easy one but I'm not too well versed on Macros /
VBA.

I have a worksheet with ever expanding data - rows at the bottom of the data
are continually added. I have a simple macro that sorts all of the data
according to preset parameters and selects the next blank cell in column A,
ready for more data:

Sub Macro5()
Range("SortRange").Select
Selection.Sort Key1:=Range("SortRange"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom
Do Until ActiveCell.Value = IsEmpty(True)
ActiveCell.Offset(1, 0).Activate
Loop
End Sub

When running the Macro, this leaves all of the cells in the range 'selected'
(ie; coloured-over). What do I need to add to the Macro to just select the
cell in Column A and remove the highlighting from all the other cells?

Thanks.
 
D

Don Guillett

try
Sub sortsortrange()
Range("SortRange").Sort Key1:=Range("SortRange"), _
Order1:=xlAscending
End Sub
 
T

Terry Bennett

Doesn't seem very keen on this. Am I adding on to the end of the existing
script?
 
D

Don Guillett

did you try it?
I assume that "sortrange" is a defined name that will automatically adjust
with each entry
something like.
=offset($a$1,0,0,counta(a:a),5)

Sub sortsortrange()'I added a line
Range("SortRange").Sort Key1:=Range("SortRange"), _
Order1:=xlAscending
Range("sortrange").End(xlDown).offset(1).Select
End Sub
 
T

Terry Bennett

Don - correct assumption re 'SortRange'.

Sorry, but could you tell me exacty what amendments to make to the code I
listed below? As mentioned, I am a novice at VBA and I don't understand
what you're suggesting.

Thanks.
 
T

Terry Bennett

Don - almost. Only problem being that it sorts the row headers, currently
in row 3, as well! The existing Macro doesn't do that. Otherwise it seems
to be good!
 
T

Terry Bennett

Don - my mistake - the range was wrongly defined.

All seems to work very well. Thanks for your help!

Terry
 
Top