Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This line:
With ActiveSheet.Range("A2:E137") would become with Selection FrankTimJr wrote: 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 -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Install Office Standard XP on Vista. Uninstall Office 2007 Trial? | Excel Discussion (Misc queries) | |||
Office 2007 compatibility pack on Office 2003 (slow network file | Setting up and Configuration of Excel | |||
sort function for dates does not sort properly in Office 2007 Exc. | Excel Worksheet Functions | |||
Problem with Interop.Excel after uninstalling Office 2007 and installing Office 2003 | Excel Programming |