Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Sort in Office 2007

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Sort in Office 2007

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   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Sort in Office 2007

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Sort in Office 2007

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   Report Post  
Posted to microsoft.public.excel.programming
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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Sort in Office 2007

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Install Office Standard XP on Vista. Uninstall Office 2007 Trial? Machete Excel Discussion (Misc queries) 1 August 11th 09 03:54 AM
Office 2007 compatibility pack on Office 2003 (slow network file fox_mulder33 Setting up and Configuration of Excel 0 January 2nd 08 03:28 PM
sort function for dates does not sort properly in Office 2007 Exc. Rosalie Excel Worksheet Functions 1 November 22nd 07 10:25 PM
Problem with Interop.Excel after uninstalling Office 2007 and installing Office 2003 Bill F[_2_] Excel Programming 2 May 2nd 07 02:52 PM


All times are GMT +1. The time now is 03:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"