PC Review


Reply
Thread Tools Rate Thread

Changing the range of a table sort

 
 
RedHook
Guest
Posts: n/a
 
      30th May 2006
Hi All

I have a simpple player league table as shown below:

Pos Player Points
1 Tom 124
2 Linda 122
3 Harry 107
4 Jayne 100
4 Bob 100
5 Steve 89

I use the Sort method in the worksheet_change method to sort the table
as follows:
.Columns("B:C").Sort Key1:=Range("C2"), _
Order1:=xlDescending, _
Key2:=Range("B2"), _
Order2:=xlAscending, _
Header:=xlYes

This all works fine, but if I insert say a couple of new rows before
the table so that the Player and Points cells are at C4 and B4
respectivelly, even if I change the Range parameters in the sort call
to C4 and B4 the sort fails - seems to think I'm still using the
original locations(C2 and B2) - I've saved and reopend the worksheet
but still see the same behaviour.

Any ideas what I've done wrong ?

TIA
RH

 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWFyY2Vsbw==?=
Guest
Posts: n/a
 
      30th May 2006
Red, when you change the spreadsheet, the VBA code does not change, you
should go to the code and change manualy the order keys

hope it helps and thanks for the feedback
Regards from Brazil
Marcelo



"RedHook" escreveu:

> Hi All
>
> I have a simpple player league table as shown below:
>
> Pos Player Points
> 1 Tom 124
> 2 Linda 122
> 3 Harry 107
> 4 Jayne 100
> 4 Bob 100
> 5 Steve 89
>
> I use the Sort method in the worksheet_change method to sort the table
> as follows:
> .Columns("B:C").Sort Key1:=Range("C2"), _
> Order1:=xlDescending, _
> Key2:=Range("B2"), _
> Order2:=xlAscending, _
> Header:=xlYes
>
> This all works fine, but if I insert say a couple of new rows before
> the table so that the Player and Points cells are at C4 and B4
> respectivelly, even if I change the Range parameters in the sort call
> to C4 and B4 the sort fails - seems to think I'm still using the
> original locations(C2 and B2) - I've saved and reopend the worksheet
> but still see the same behaviour.
>
> Any ideas what I've done wrong ?
>
> TIA
> RH
>
>

 
Reply With Quote
 
RedHook
Guest
Posts: n/a
 
      31st May 2006
Hi Marcelo

I did change the VBA code to reflect what I thought should be the new
Range values C4 and B4(i.e. the new cell positions of the table column
headers; Player and Points), but it makes no difference - I'm obviously
missing something basic here but I can't see what !

Regards
RH
Marcelo wrote:
> Red, when you change the spreadsheet, the VBA code does not change, you
> should go to the code and change manualy the order keys
>
> hope it helps and thanks for the feedback
> Regards from Brazil
> Marcelo
>
>
>
> "RedHook" escreveu:
>
> > Hi All
> >
> > I have a simpple player league table as shown below:
> >
> > Pos Player Points
> > 1 Tom 124
> > 2 Linda 122
> > 3 Harry 107
> > 4 Jayne 100
> > 4 Bob 100
> > 5 Steve 89
> >
> > I use the Sort method in the worksheet_change method to sort the table
> > as follows:
> > .Columns("B:C").Sort Key1:=Range("C2"), _
> > Order1:=xlDescending, _
> > Key2:=Range("B2"), _
> > Order2:=xlAscending, _
> > Header:=xlYes
> >
> > This all works fine, but if I insert say a couple of new rows before
> > the table so that the Player and Points cells are at C4 and B4
> > respectivelly, even if I change the Range parameters in the sort call
> > to C4 and B4 the sort fails - seems to think I'm still using the
> > original locations(C2 and B2) - I've saved and reopend the worksheet
> > but still see the same behaviour.
> >
> > Any ideas what I've done wrong ?
> >
> > TIA
> > RH
> >
> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sort a changing range =?Utf-8?B?amh5YXR0?= Microsoft Excel Misc 0 18th Sep 2007 08:04 PM
seting a changing range to sort on 3 different sheets =?Utf-8?B?amh5YXR0?= Microsoft Excel Programming 2 18th Sep 2007 04:40 PM
automatically sort a table after changing a cell =?Utf-8?B?QWFyb24=?= Microsoft Excel Misc 1 26th Jul 2006 06:30 PM
Changing Pivot Table Range Rod Microsoft Excel Programming 4 10th Apr 2004 01:47 AM
changing sort for pivot table fields Stan R Microsoft Excel Programming 1 16th Aug 2003 12:32 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:13 AM.