LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 155
Default Select a list, then sort

Thank you

"Bob Phillips" wrote:

Before the sort.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Tanya" wrote in message
...
Thank you Bob, please forgive me, I am only beginning to learn VBA. I
understand where to alter order1 but have no idea how to place the rest of
your code.

Regards
Tanya



Sub SortByName()
'
' Sort by Mechanic's Name Macro
' Macro recorded 3/03/2007 by Tanya
'
'
Range("B10").Select
ActiveCell.Sort Key1:=Range("B11"), Order1:=iSortOrder, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal


End Sub

"Bob Phillips" wrote:

iSortOrder = xlAscending
sSortOrder = Inputbox("Sort ascending(A) or descending(D)?",default:="A")
If UCase(sSortOrder) = "D" Then
iSortOrder = xlDescending
End If

and change the Order1 property from xlAscending to iSortOrder

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Tanya" wrote in message
...
Jay is it at all possible to add a line to this code which will provide
a
msg
box which allows the user to decide whether to sort by assending or
descending?

"Jay" wrote:

Yes, makes sense. The sort method automatically senses the size of
the
list;
here's how you can take advantage of that fact.

The sort statement produced by the macro recorder will look something
like:
Range("A2:C25").Sort Key1:=Range("A3"), Order1:=xlAscending,
Header:=
_
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Replace "Range("A2:C25")" with "ActiveCell", so it'll look like
"ActiveCell.Sort Key1...etc.

Then, add a line before that sort statement:
Range("A2").Select 'Or whatever the uppermost cell in the list is.

Then run it!
--
Jay


"Tanya" wrote:

Thank you Jay for replying so promptly.

I have already tried this. My problem is that the table changes as
new
members are added. Therefore the range is not constant... I think
I
need a
way for the macro to identify the headings and last entry in the
table.
At
least that is where my thoughts are heading. Does that make any
sense?

Regards
Tanya

"Jay" wrote:

Hi Tanya -

Try the macro recorder for this process. It will produce VB macro
code that
you can easily modify.

First, select any cell in the list. then:

Step 1: Tools | Macro | Record New Macro (a StopRecording menu
bar
will
appear - disregard it for now)

Step 2: manually apply the sort (Data | Sort | etc...)

Step 3: click "Stop Recording" (on the StopRecording menu bar that
appeared
in Step 1.

Step 4: Open the VB editor (Alt-F11) to find the sorting statement
in
the
Macro produced by Steps 1-3. Modify as necessary.

--
Jay


"Tanya" wrote:

Hi
Could someone help me please? I need to be able to select a
list
in sheet
and then sort by particular heading. I am new to macros. Any
guidance would
be appreciated.
Thanks in advance








 
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
I want sort a list but the sort is unlit on the home tab how do I chetrx Excel Worksheet Functions 3 November 14th 08 11:47 PM
DATA VALIDATION LIST- CAN I SELECT FROM LIST WITHOUT SCROLLING Bellyjean Excel Worksheet Functions 1 March 7th 08 09:46 PM
how to randomly select a name in a list and then the select the ne [email protected] Excel Worksheet Functions 1 September 20th 06 08:09 AM
Excel sort by Fill Color by custom list sort Dash4Cash Excel Discussion (Misc queries) 2 July 29th 05 10:45 PM
Select and then sort a list Ian_Limbo[_2_] Excel Programming 8 January 6th 05 03:15 PM


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