Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Benny Thomas
  Where is Benny Thomas?
 Jeddah
 Saudi Arabia
 Benny Thomas
 To: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 Tags
Subject: RE: Sorting Excel Worksheet rows
Thread ID: 288772 Message ID: 288893 # Views: 24 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Microsoft Office Automation
Date: Saturday, December 25, 2010 11:46:15 AM         
   


> > Hi Excel experts,
> >
> > Can somebody tell me how to sort rows in a excel worksheet within VFP by office automation? I need to sort entire rows on colum 'B'. First 2 or 3 rows are column heading. I do not know the last row number, this varies for each worksheet. Total number of columns are fixed. Thanks in advance.
> >
> > Benny
>
>
#Define xlAscending	1
> #Define xlDescending	2
> #Define xlSortRows	2
> #Define xlSortColumns	1
> #Define xlSortLabels	2
> #Define xlSortValues	1
> #Define xlGuess	0
> #Define xlLeftToRight	2
> #Define xlTopToBottom	1
> 
> oSheet = oExcel.ActiveWorkbook.ActiveSheet
> With oSheet
>   oRange = .UsedRange.Offset( 2, 0 ) && first 2 or 3 are headers
>   oRange.Sort( .Range("B1"), xlAscending,,,,,, xlGuess,, .F., xlTopToBottom )
> Endwith
> 

>
> Cetin Basoz
>
> .Net has got better.Think about moving - check my blog:
> Blog (main)
> Blog (mirror)

Thanks Cetin. This is exactly what I need.

Benny

ENTIRE THREAD

Sorting Excel Worksheet rows Posted by Benny Thomas @ 12/23/2010 11:18:07 PM
RE: Sorting Excel Worksheet rows Posted by Mike Gagnon @ 12/23/2010 11:54:39 PM
RE: Sorting Excel Worksheet rows Posted by Jun Tangunan @ 12/24/2010 1:47:57 AM
RE: Sorting Excel Worksheet rows Posted by Benny Thomas @ 12/24/2010 9:15:07 AM
RE: Sorting Excel Worksheet rows Posted by Cetin Basoz @ 12/24/2010 4:48:37 PM
RE: Sorting Excel Worksheet rows Posted by Benny Thomas @ 12/25/2010 11:46:15 AM