Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Automatic Sorting?

Is there a way that Excel can automatically sort a column?

I am working on a spreadsheet where the end user "cut and
pastes" data from an outside source to Excel. The Excel
spreadsheet then manipulates the data and creates a one
page presentation piece.

One of the features on the presentation piece is a "Top
10 Client" listing - this is why I want automatic sorting.

I know how to sort the data manually, using the Data -
Sort technique, but I was hoping I wouldn't have to train
the end users how to perform that step.

Any ideas?

Thanks in advance for your help.


Scott B. Hogle
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Automatic Sorting?

turn on the macro recorder, then do a manual sort.

Turn off the macro recorder.

This will show you the code you need to do the sort.

put this code in the worksheet change event and put in a condition that
"target" is in the range you want sorted.

for example:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Intersect(Target, Columns(1)) Is Nothing Then
Range("A1").Sort Key1:=Range("A1"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End If
End Sub


--
Regards,
Tom Ogilvy


"Scott B. Hogle" wrote in message
...
Is there a way that Excel can automatically sort a column?

I am working on a spreadsheet where the end user "cut and
pastes" data from an outside source to Excel. The Excel
spreadsheet then manipulates the data and creates a one
page presentation piece.

One of the features on the presentation piece is a "Top
10 Client" listing - this is why I want automatic sorting.

I know how to sort the data manually, using the Data -
Sort technique, but I was hoping I wouldn't have to train
the end users how to perform that step.

Any ideas?

Thanks in advance for your help.


Scott B. Hogle



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Automatic Sorting?

Scott,

You can do it without sorting.

On the summary page, for the Top 10, you can get the value like so

=LARGE(Sheet1!A:A,ROW(A1))

and just copy down 9 rows.

If you want some related data, use a formula like

INDEX(Sheet1!B:B,MATCH(A1,Sheet1!A:A,0))


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Scott B. Hogle" wrote in message
...
Is there a way that Excel can automatically sort a column?

I am working on a spreadsheet where the end user "cut and
pastes" data from an outside source to Excel. The Excel
spreadsheet then manipulates the data and creates a one
page presentation piece.

One of the features on the presentation piece is a "Top
10 Client" listing - this is why I want automatic sorting.

I know how to sort the data manually, using the Data -
Sort technique, but I was hoping I wouldn't have to train
the end users how to perform that step.

Any ideas?

Thanks in advance for your help.


Scott B. Hogle



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 691
Default Automatic Sorting?

Hi Scott,
If you try for completely automatic, it will interfere with you
entering data as you try to change the next cell. I just
created a pair of worksheet macros for someone else today,
see Sorting triggered by an Event Macro (#activate)
http://www.mvps.org/dmcritchie/excel...g.htm#activate
The event macros are Worksheet_Activate and Worksheet_BeforeDoubleClick

Actually after rereading your post, perhaps the topic above that one.

Seems strange another person also mentioned copying and
pasting from HTML you might as well check my reply to Ron.
http://google.com/groups?threadm=Opf...GP09.phx.g bl
until Google slurps it up in twelve hours you may have to look here

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Scott B. Hogle" wrote ...
Is there a way that Excel can automatically sort a column?

I am working on a spreadsheet where the end user "cut and
pastes" data from an outside source to Excel. The Excel
spreadsheet then manipulates the data and creates a one
page presentation piece.

One of the features on the presentation piece is a "Top
10 Client" listing - this is why I want automatic sorting.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 691
Default Automatic Sorting?

Hi Bob,
nice resolution / interpretation of what appears to be
really wanted by a means other than sorting. -- David

"Bob Phillips" wrote ...
You can do it without sorting.

On the summary page, for the Top 10, you can get the value like so
=LARGE(Sheet1!A:A,ROW(A1))
and just copy down 9 rows.

If you want some related data, use a formula like
INDEX(Sheet1!B:B,MATCH(A1,Sheet1!A:A,0))

"Scott B. Hogle" wrote
One of the features on the presentation piece is a "Top
10 Client" listing - this is why I want automatic sorting.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Automatic Sorting?

Thank-you David, appreciated.

Bob

"David McRitchie" wrote in message
...
Hi Bob,
nice resolution / interpretation of what appears to be
really wanted by a means other than sorting. -- David

"Bob Phillips" wrote ...
You can do it without sorting.

On the summary page, for the Top 10, you can get the value like so
=LARGE(Sheet1!A:A,ROW(A1))
and just copy down 9 rows.

If you want some related data, use a formula like
INDEX(Sheet1!B:B,MATCH(A1,Sheet1!A:A,0))

"Scott B. Hogle" wrote
One of the features on the presentation piece is a "Top
10 Client" listing - this is why I want automatic sorting.





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Automatic Sorting?

Thanks to everyone!

I used Bob's suggestion and it worked great. I never
would have figured that out on my own.

I still don't know how the INDEX Function works, but I
was able to use Bob's coding and now the client name and
sales results are tied together.

Thanks again, you guys are awesome!


SBH
-----Original Message-----
Scott,

You can do it without sorting.

On the summary page, for the Top 10, you can get the

value like so

=LARGE(Sheet1!A:A,ROW(A1))

and just copy down 9 rows.

If you want some related data, use a formula like

INDEX(Sheet1!B:B,MATCH(A1,Sheet1!A:A,0))


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Scott B. Hogle"

wrote in message
...
Is there a way that Excel can automatically sort a

column?

I am working on a spreadsheet where the end user "cut

and
pastes" data from an outside source to Excel. The

Excel
spreadsheet then manipulates the data and creates a one
page presentation piece.

One of the features on the presentation piece is a "Top
10 Client" listing - this is why I want automatic

sorting.

I know how to sort the data manually, using the Data -
Sort technique, but I was hoping I wouldn't have to

train
the end users how to perform that step.

Any ideas?

Thanks in advance for your help.


Scott B. Hogle



.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Automatic Sorting?

Hi Scott,

INDEX, as help says, returns the value of an element in a table or an array,
selected by the row and column number indexes. So it is similar to the
LOOKUP functions but finds the value based upon a row and column index
rather than a value. Because of this, it is often combined with MATCH which
does lookup a value, but returns the row number.

So in the example I gave

MATCH(A1,Sheet1!A:A,0)

finds the row within the column of our value and returns the row number, and
then

INDEX(Sheet1!B:B,MATCH(A1,Sheet1!A:A,0))

returns the value in column B for our row. In the example I gave, VLOOKUP
would also have worked

=VLOOKUP(A1,Sheet1!A1:B11,2,FALSE)

but INDEX & MATCH works better when the data is not organised with the key
value to the left. In the example I gave I felt that the data was more
likely to be something like

Client Id || Client Name || some other data || value || etc

so the lookup is on value, INDEX and MATCH can handle this.


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Scott B. Hogle" wrote in message
...
Thanks to everyone!

I used Bob's suggestion and it worked great. I never
would have figured that out on my own.

I still don't know how the INDEX Function works, but I
was able to use Bob's coding and now the client name and
sales results are tied together.

Thanks again, you guys are awesome!


SBH
-----Original Message-----
Scott,

You can do it without sorting.

On the summary page, for the Top 10, you can get the

value like so

=LARGE(Sheet1!A:A,ROW(A1))

and just copy down 9 rows.

If you want some related data, use a formula like

INDEX(Sheet1!B:B,MATCH(A1,Sheet1!A:A,0))


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Scott B. Hogle"

wrote in message
...
Is there a way that Excel can automatically sort a

column?

I am working on a spreadsheet where the end user "cut

and
pastes" data from an outside source to Excel. The

Excel
spreadsheet then manipulates the data and creates a one
page presentation piece.

One of the features on the presentation piece is a "Top
10 Client" listing - this is why I want automatic

sorting.

I know how to sort the data manually, using the Data -
Sort technique, but I was hoping I wouldn't have to

train
the end users how to perform that step.

Any ideas?

Thanks in advance for your help.


Scott B. Hogle



.



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Automatic Sorting?



How about 2 or more fileds(different name) have same sorting criteria?
After using index(A:A, match(A:A,xxxx), they share same name.

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Automatic Sorting?


I also want to thank Bob. This is something I've been scratching my head
over for a week or so. Finally resorted to searching on the Internet
rather than the masochistic pleasure of trying to work it out for my
self.

So far I've only tried Bob's original suggestion (LARGE / INDEX) and
it's great. It is true that if you have two results exactly the same
then there is a problem.

With my needs I am happy to add a very small, unique (0.000x) number to
the original. Therefore every number will always be slightly different,
then I can just show the final number to only 2 decimal places.

Regards

William


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
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
Automatic Sorting? Ted[_6_] Excel Worksheet Functions 6 January 10th 10 06:01 PM
Automatic sorting (giving max and min) based on custom sorting lis Joe Lewis[_2_] Excel Worksheet Functions 4 November 23rd 08 05:12 AM
automatic sorting Curious Excel Discussion (Misc queries) 1 September 12th 08 10:56 AM
Automatic sorting [email protected] Excel Worksheet Functions 0 June 26th 07 09:24 PM
automatic sorting gmisi Excel Worksheet Functions 3 October 11th 06 11:33 PM


All times are GMT +1. The time now is 10:36 AM.

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"