View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Custom Sort Problems

Hi Ken,

See MSKB article # 134913:

XL: GetCustomListNum Returns Unexpected List Number

http://support.microsoft.com/default.aspx?kbid=134913


---
Regards,
Norman



"Ken McLennan" wrote in message
.. .
G'day there One & All,

Here I am back again, with another problem. This time while trying
to sort with a custom list.

Here's the code I'm trying to use:

Private Sub oBtnRank_Click()
If oBtnRank Then gRng.Sort _
key1:=Range("Rank"), _
order1:=srtDir, _
header:=xlYes, _
ordercustom:=cstmSrtRngCnt
gStr = "Rank"
End Sub

This is the code from one of the OptionButtons on my userform.
Except for the "ordercustom" part, the code is exactly the same as for 3
other optionbuttons, but they sort my range alphabetically (which is
what they're supposed to do).

This particular option is supposed to sort via my custom list, but
for some reason it insists on sorting alphabetically and ignoring my
custom list.

To explain a little; gRng has been "set" to a named dynamic range.
Range("Rank") is the heading for the third column in this range.
"srtDir" is a string which has been set to Ascending or Descending.
"cstmSrtRngCnt" is a numeric variable containing the count of custom
lists - it's determined by

If Not dSht.Range("wrkRanks").Cells.Count = 0 Then
Application.AddCustomList (dSht.Range("wrkRanks"))
End If
cstmSrtRngCnt = Application.CustomListCount

this is from the "Auto_Open" procedure.

My best friend Google has provided me with one or two examples, but not
a lot that seems applicable. There are heaps of descriptions of how to
use custom lists directly from the sheet, but I've not found a lot that
demonstrates how to do it in VB.

If anyone can shed some light on this for me I'd be very grateful.

Thanks very much for listening,
--
Ken McLennan
Qld, Australia