Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Help with SORT property in xl2007 and xl2007 !!!!!!!!!!!!!!!!!!!!

I have this line of code in my macro. Someone with Excel 2003 can go past it.

BOReportWS.Sort.SortFields.Clear

Is there a way to get it to run in xl2003?


'BOReportWS.Sort.SortFields.Add Key:=Range("A3:A" & BO_DownloadWS_lastRow)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Help with SORT property in xl2007 and xl2007 !!!!!!!!!!!!!!!!!!!!

xl2007 still supports the old syntax. So you could create the macro (record
it???) in xl2003 and it'll work ok.

This may help (or not!):

Dim wks As Worksheet
Dim myRng As Range

Set wks = Worksheets("Sheet9999")

With wks
Set myRng = .Range("A3:x" & BO_DownloadWS_lastRow)
End With

With myRng
.Cells.Sort _
key1:=.Columns(1), order1:=xlAscending, _
key2:=.Columns(3), order1:=xlAscending, _
header:=xlYes
End With

This is sorting A3:X(lastrow) by columns A and C. And the data has header in
the first row.



Ayo wrote:

I have this line of code in my macro. Someone with Excel 2003 can go past it.

BOReportWS.Sort.SortFields.Clear

Is there a way to get it to run in xl2003?

'BOReportWS.Sort.SortFields.Add Key:=Range("A3:A" & BO_DownloadWS_lastRow)


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Help with SORT property in xl2007 and xl2007 !!!!!!!!!!!!!!!!

Thanks Dave.
I was thinking of actually using both versions by inserting an:
If Application.Version12.0 then
Use xl2007 syntax
ElseIf Application.Version<12.0 then
Use xl2003 syntax
End If

"Dave Peterson" wrote:

xl2007 still supports the old syntax. So you could create the macro (record
it???) in xl2003 and it'll work ok.

This may help (or not!):

Dim wks As Worksheet
Dim myRng As Range

Set wks = Worksheets("Sheet9999")

With wks
Set myRng = .Range("A3:x" & BO_DownloadWS_lastRow)
End With

With myRng
.Cells.Sort _
key1:=.Columns(1), order1:=xlAscending, _
key2:=.Columns(3), order1:=xlAscending, _
header:=xlYes
End With

This is sorting A3:X(lastrow) by columns A and C. And the data has header in
the first row.



Ayo wrote:

I have this line of code in my macro. Someone with Excel 2003 can go past it.

BOReportWS.Sort.SortFields.Clear

Is there a way to get it to run in xl2003?

'BOReportWS.Sort.SortFields.Add Key:=Range("A3:A" & BO_DownloadWS_lastRow)


--

Dave Peterson
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Help with SORT property in xl2007 and xl2007 !!!!!!!!!!!!!!!!

Unless you're doing something unique to xl2007, I wouldn't bother.

Ayo wrote:

Thanks Dave.
I was thinking of actually using both versions by inserting an:
If Application.Version12.0 then
Use xl2007 syntax
ElseIf Application.Version<12.0 then
Use xl2003 syntax
End If

"Dave Peterson" wrote:

xl2007 still supports the old syntax. So you could create the macro (record
it???) in xl2003 and it'll work ok.

This may help (or not!):

Dim wks As Worksheet
Dim myRng As Range

Set wks = Worksheets("Sheet9999")

With wks
Set myRng = .Range("A3:x" & BO_DownloadWS_lastRow)
End With

With myRng
.Cells.Sort _
key1:=.Columns(1), order1:=xlAscending, _
key2:=.Columns(3), order1:=xlAscending, _
header:=xlYes
End With

This is sorting A3:X(lastrow) by columns A and C. And the data has header in
the first row.



Ayo wrote:

I have this line of code in my macro. Someone with Excel 2003 can go past it.

BOReportWS.Sort.SortFields.Clear

Is there a way to get it to run in xl2003?

'BOReportWS.Sort.SortFields.Add Key:=Range("A3:A" & BO_DownloadWS_lastRow)


--

Dave Peterson
.


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default Help with SORT property in xl2007 and xl2007 !!!!!!!!!!!!!!!!!!!!

On Apr 28, 11:01*pm, Dave Peterson wrote:
xl2007 still supports the old syntax. *So you could create the macro (record
it???) in xl2003 and it'll work ok.

This may help (or not!):

* * Dim wks As Worksheet
* * Dim myRng As Range

* * Set wks = Worksheets("Sheet9999")

* * With wks
* * * * Set myRng = .Range("A3:x" & BO_DownloadWS_lastRow)
* * End With

* * With myRng
* * * * .Cells.Sort _
* * * * * * key1:=.Columns(1), order1:=xlAscending, _
* * * * * * key2:=.Columns(3), order1:=xlAscending, _
* * * * * * header:=xlYes
* * End With

This is sorting A3:X(lastrow) by columns A and C. *And the data has header in
the first row.

Ayo wrote:

I have this line of code in my macro. Someone with Excel 2003 can go past it.


BOReportWS.Sort.SortFields.Clear


Is there a way to get it to run in xl2003?


'BOReportWS.Sort.SortFields.Add Key:=Range("A3:A" & BO_DownloadWS_lastRow)


--

Dave Peterson


This line is wrong key2:=.Columns(3), order1:=xlAscending, _
This line is correct key2:=.Columns(3), order2:=xlAscending, _


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Help with SORT property in xl2007 and xl2007 !!!!!!!!!!!!!!!!!!!!

Thanks for the correction.



Javed wrote:
<<snipped

This line is wrong key2:=.Columns(3), order1:=xlAscending, _
This line is correct key2:=.Columns(3), order2:=xlAscending, _


--

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
XL2007: Down < down on Enter? GeoBrooks Excel Discussion (Misc queries) 3 December 4th 09 04:00 PM
XL2007: Add my certificate? Ed from AZ Excel Programming 0 September 23rd 09 04:12 PM
Guidance, please (xl2007) Kragelund Excel Programming 5 December 8th 08 08:28 PM
xl2007 Nigel[_2_] Excel Programming 5 October 12th 07 12:28 AM
Max row Height in XL2007 Billy Liddel Excel Discussion (Misc queries) 1 May 19th 07 11:56 AM


All times are GMT +1. The time now is 07:34 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"