Sorting worksheets alphabetically (in Turkish specific characters)

S

serdar

This scripts sorts the worksheet regularly, except it -naturally- puts the
sheets with turkish specific characters to wrong place. Because Turkish
specific characters have greater ASCII values.

For example we have a lowercase "i" with no dot on, and it is just before
letter "i" in the alphabet (but not in the ASCII table:)


-What is the most straight forward method to handle specific characters in
your opinion?
 
S

serdar

sorry this is the code:


Public Sub SortSheets()

Dim SheetCount As Integer
Dim i As Integer
Dim j As Integer

SheetCount = Worksheets.Count

For i = 1 To SheetCount - 1
For j = i + 1 To SheetCount
If Worksheets(j).Name < Worksheets(i).Name Then
Worksheets(j).Move Before:=Worksheets(i)
End If
Next j
Next i





End Sub
 
J

Jim Cone

serdar,

I don't believe there is a straight forward way to handle it.
What you could do is...
1. set up two arrays, one with the special characters and
the other with replacement characters - probably the next
ASCII recognizable character.
2. for each worksheet name substitute any special character with
its replacement character.
3. do not actually change the worksheet names but place the
revised names in a two dimensional array...
nameArray(1, 1) = revised name
nameArray(1, 2) = actual name
4. sort the nameArray by the revised names but keep the
actual names adjacent to their replacement names.
5. sort the worksheets by the position of the actual name in the array.
(last array item goes to sheet position 1, next to last item goes to
sheet position 1 etc)
I use something very similar to sort worksheets by numeric values
contained in the worksheet name.
It is very fast, as each worksheet is only moved once.

Regards,
Jim Cone
San Francisco, USA

This scripts sorts the worksheet regularly, except it -naturally- puts the
sheets with turkish specific characters to wrong place. Because Turkish
specific characters have greater ASCII values.
For example we have a lowercase "i" with no dot on, and it is just before
letter "i" in the alphabet (but not in the ASCII table:)
-What is the most straight forward method to handle specific characters in
your opinion?
 
Top