In a previous topic at this link https://eileenslounge.com/viewtopic.php?f=30&t=38460
Mr. Hans offered a UDF that calculates the letters' weight
Code: Select all
Function Weight(s As String) As Long
Dim Letters, Weights
Dim i As Long
Letters = Array("A", "B", "C", ..., "Z")
Weights = Array(1, 5, 3, ..., 2)
For i = 1 To Len(s)
Weight = Weight + Weights(Asc(Mid(s, i, 1)) - 65)
Next i
End Function
What I need is to sort the words by letters' weight from top weight to lowest weight
Here's the command button code that I am using to collect the words from the listboxes on UserForm1
Code: Select all
Private Sub CommandButton3_Click()
Dim v, a(), i As Integer, ii As Integer, k As Long
k = 0
For i = 1 To 6
With Me.Controls("ListBox" & i)
If .ListCount > 0 Then
v = .List
For ii = LBound(v) To UBound(v)
ReDim Preserve a(k)
a(k) = v(ii, 0)
k = k + 1
Next ii
End If
End With
Next i
UserForm3.ListBox1.List = a
UserForm3.Show
End Sub