Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Sort on Tab Change

Is there a way to trigger sorting of a column, when I change tabs? I have a
dataset that I use for input and a different tab which is a leaderboard. I
want to sort the leaderboard by high score every time I change to that tab.
I currently have a macro button I click to sort by high score, then I have
to click the leadboard tab. I'd obviously like to click the leaderboard tab
and have the data sorted by high score. Just attempting to combine 2 steps.

step 1 - Sort input form by highscore
step 2 - open the leaderboard tab



Thanks,


Jeff



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sort on Tab Change


right-click the tab of the leaderboard sheet and choose 'View Code..'
You'll be plonked into a pane whee there are two dropdown fields.
Choose 'Worksheet from the left one, then 'Activate' from the right
one.
It should then plonk the cursor between the following two lines:

Private Sub Worksheet_Activate()

End Sub

Inbetween them type the name of your macro.

Close, that newly opened Visual Basic window altogether and, fingers
crossed, when you activate that sheet from another sheet (ie. when you
change to that tab), your sort macro will kick in.

If the sorting is to take place on a sheet other than the leaderboard
tab, it may not work properly, depending on what's in that sort macro.
Post again if it goes wrong.


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?u=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=196249

http://www.thecodecage.com/forumz

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default Sort on Tab Change

Put something like this in the Leaderborad Worksheet module...

Private Sub Worksheet_Activate()
Range("A:C").Sort Key1:=Range("C2"), _
Order1:=xlDescending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

Where the range is the columns desired and the key is the column where the
scores are.

--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown



"Joe Schmoe" wrote:

Is there a way to trigger sorting of a column, when I change tabs? I have a
dataset that I use for input and a different tab which is a leaderboard. I
want to sort the leaderboard by high score every time I change to that tab.
I currently have a macro button I click to sort by high score, then I have
to click the leadboard tab. I'd obviously like to click the leaderboard tab
and have the data sorted by high score. Just attempting to combine 2 steps.

step 1 - Sort input form by highscore
step 2 - open the leaderboard tab



Thanks,


Jeff



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Sort on Tab Change

The problem is the sort has to be done on the data input tab before the
macro can run. It has to happen in the following order.
1. On the Input tab - sort by highscore
2. Open leaderboard tab

Thanks again


"p45cal" wrote in message
...

right-click the tab of the leaderboard sheet and choose 'View Code..'
You'll be plonked into a pane whee there are two dropdown fields.
Choose 'Worksheet from the left one, then 'Activate' from the right
one.
It should then plonk the cursor between the following two lines:

Private Sub Worksheet_Activate()

End Sub

Inbetween them type the name of your macro.

Close, that newly opened Visual Basic window altogether and, fingers
crossed, when you activate that sheet from another sheet (ie. when you
change to that tab), your sort macro will kick in.

If the sorting is to take place on a sheet other than the leaderboard
tab, it may not work properly, depending on what's in that sort macro.
Post again if it goes wrong.


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?u=558
View this thread:
http://www.thecodecage.com/forumz/sh...d.php?t=196249

http://www.thecodecage.com/forumz

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Sort on Tab Change

Unfortunately that won't work. I'm using the "indirect" command to point to
the dataset on the input worksheet. So the data resides on the input tab.


"Gary Brown" <junk_at_kinneson_dot_com wrote in message
...
Put something like this in the Leaderborad Worksheet module...

Private Sub Worksheet_Activate()
Range("A:C").Sort Key1:=Range("C2"), _
Order1:=xlDescending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

Where the range is the columns desired and the key is the column where the
scores are.

--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown



"Joe Schmoe" wrote:

Is there a way to trigger sorting of a column, when I change tabs? I
have a
dataset that I use for input and a different tab which is a leaderboard.
I
want to sort the leaderboard by high score every time I change to that
tab.
I currently have a macro button I click to sort by high score, then I
have
to click the leadboard tab. I'd obviously like to click the leaderboard
tab
and have the data sorted by high score. Just attempting to combine 2
steps.

step 1 - Sort input form by highscore
step 2 - open the leaderboard tab



Thanks,


Jeff



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sort on Tab Change


Joe Schmoe;701542 Wrote:

Unfortunately that won't work. I'm using the "indirect" command to
point to
the dataset on the input worksheet. So the data resides on the input

tab.




Show us the sorting code, what's in the indirect cells, the name of the
sheet on which the sorting takes place. It shouldn't be a problem.


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?u=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=196249

http://www.thecodecage.com/forumz

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Sort on Tab Change


Here is the reference to the Input form named "Scores"
=INDIRECT("Scores!E"& ROW(E3))


Here is the sort:

Private Sub Worksheet_Activate()
DynSortD "E3"
End Sub


Private Sub DynSortD(sKeyAddress As String)
Dim sortRange As Range
Dim sKey1 As Range
Dim lastRow As Long
Const TestCol = "D"
Const firstColToSort = "A"
Const lastColToSort = "O"
Const firstRowToSort = 3

lastRow = Range(TestCol & Rows.Count).End(xlUp).Row
If lastRow < firstRowToSort Then
Exit Sub ' nothing to sort
End If
Set sortRange = Range(firstColToSort & firstRowToSort & ":" &
lastColToSort & lastRow)
Set sKey1 = Range(sKeyAddress)

sortRange.Sort Key1:=sKey1, Order1:=xlDescending, Header:=xlNo,
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
DataOption1:=xlSortTextAsNumbers
End Sub
_________________________________


"p45cal" wrote in message
...

Joe Schmoe;701542 Wrote:

Unfortunately that won't work. I'm using the "indirect" command to
point to
the dataset on the input worksheet. So the data resides on the input

tab.




Show us the sorting code, what's in the indirect cells, the name of the
sheet on which the sorting takes place. It shouldn't be a problem.


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?u=558
View this thread:
http://www.thecodecage.com/forumz/sh...d.php?t=196249

http://www.thecodecage.com/forumz

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sort on Tab Change


I'm not sure that this isn't more complex than it needs to be but so
that I don't lose any functionality can you tell me the sheet name and
cell address of this formula (and is it just one cell which has a
formula like this?)?:
=INDIRECT("Scores!E"& ROW(E3))

Which code module is the code below in? If it's a sheet code module,
which sheet?

Private Sub DynSortD(sKeyAddress As String)
Dim sortRange As Range
Dim sKey1 As Range...
...

(If you want, you can PM me at thecodecage with a view to your sending
me the file to look at. Otherwise where are you posting these
messages?)


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?u=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=196249

http://www.thecodecage.com/forumz

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
Hyperlinks change during sort Richard Excel Discussion (Misc queries) 0 March 31st 09 02:13 PM
Some columns don't change when I sort lawhoo Excel Discussion (Misc queries) 1 September 18th 08 04:54 PM
Ascending Sort formula, change to neg #: descending sort.. nastech Excel Discussion (Misc queries) 6 July 2nd 07 11:00 PM
Can't Change and Re-Sort Sylvia Excel Discussion (Misc queries) 4 March 30th 05 07:07 PM
change default for sort ? Allen[_2_] Excel Programming 3 August 19th 03 01:39 AM


All times are GMT +1. The time now is 02:21 PM.

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

About Us

"It's about Microsoft Excel"