View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
FrankTimJr FrankTimJr is offline
external usenet poster
 
Posts: 16
Default Sort in Office 2007

Is there any way this code could be written where the range is selected
BEFORE the macro is run? I want to be able to select the range to sort
first, then run the macro.

XP mentioned something about a variable but I'm not sure how to write one
and if it applies to what I want to accomplish.

The code works great but I want to eliminate the range selection in the macro.

Thanks in advance.
Frank
"Dave Peterson" wrote:

If you do it right <vbg.

XP wrote:

Thanks Dave!

I'm presuming I can substitute a variable for the range...?

Thanks!

"Dave Peterson" wrote:

With ActiveSheet.Range("A2:E137")
.Cells.Sort key1:=.Columns(1), order1:=xlAscending, Header:=xlNo, _
MatchCase:=False, Orientation:=xlTopToBottom
End With

Check if the header argument is correct.


XP wrote:

Using Office 2007 and Win XP;

I recorded a macro to sort a range and I got some gobblety-gook that doesn't
run when I replay the macro.

In my code, I first select a range (e.g. A2:E137) then I want to sort on
column "A".

Can someone please post a generic code example that would do this (Office
2007)?

Thanks much in advance.

--

Dave Peterson


--

Dave Peterson