kulen_dbraco
11-26-2021, 01:08 AM
Dear VBAExpress friends,
this is my very first post on this forum... I really admire Your knowledge and enthusiasm here... You're all great!!:hi:
I have a question that might be an easy-peasy for You...
I'm dealing with worksheets in excel that are named by numbers (eg. 2.9, 2.10, 2.93) and I want to sort them numerically.
But I'm a bit confused by the decimal places that the names have, and I'm not sure how to write the right code.
When I sort them (with the macro that I'm using), names like, for example, 2.9 appears after 2.85 (which is kinda right),
but my 2.9 should be before it..... You can take a look on the photos attached.....You'll get it there :yes Thank You!
At the moment I'm using this code:
Sub WSsort()
Application.ScreenUpdating = False
Dim ShCount As Integer, i As Integer, j As Integer
ShCount = Sheets.Count
For i = 1 To ShCount - 1
For j = i + 1 To ShCount
If UCase(Sheets(j).Name) < UCase(Sheets(i).Name) Then
Sheets(j).Move before:=Sheets(i)
End If
Next j
Next i
Application.ScreenUpdating = True
End Sub
291842918529186
this is my very first post on this forum... I really admire Your knowledge and enthusiasm here... You're all great!!:hi:
I have a question that might be an easy-peasy for You...
I'm dealing with worksheets in excel that are named by numbers (eg. 2.9, 2.10, 2.93) and I want to sort them numerically.
But I'm a bit confused by the decimal places that the names have, and I'm not sure how to write the right code.
When I sort them (with the macro that I'm using), names like, for example, 2.9 appears after 2.85 (which is kinda right),
but my 2.9 should be before it..... You can take a look on the photos attached.....You'll get it there :yes Thank You!
At the moment I'm using this code:
Sub WSsort()
Application.ScreenUpdating = False
Dim ShCount As Integer, i As Integer, j As Integer
ShCount = Sheets.Count
For i = 1 To ShCount - 1
For j = i + 1 To ShCount
If UCase(Sheets(j).Name) < UCase(Sheets(i).Name) Then
Sheets(j).Move before:=Sheets(i)
End If
Next j
Next i
Application.ScreenUpdating = True
End Sub
291842918529186