A family of Microsoft word processing software products for creating web, email, and print documents.
I am a total and complete dope. Sorry for wasting everyone's time: I did not include a line in the function returning the value.
So that the episode not be a total and complete loss, I include the function below. (It is widely used in traditional Hebrew, and the abjad system in Arabic is a rough equivalent.) It covers my specific use case and is not complete (this would require mapping alternate forms of a character to the same value).
Thanks and happy holidays to all.
Function letterValue(rStr As Range) As Long
Dim ltrs As Variant
Dim c As String
Dim i As Long
Dim j As Long
Dim sum As Long
ltrs = Array(ChrW(1488), ChrW(1489), ChrW(1490), ChrW(1491), ChrW(1492), ChrW(1493), ChrW(1494), ChrW(1495), ChrW(1496), ChrW(1497), ChrW(1499), ChrW(1500), ChrW(1502),
ChrW(1504), ChrW(1505), ChrW(1506), ChrW(1508), ChrW(1510), ChrW(1511), ChrW(1512),
ChrW(1513), ChrW(1514))
For i = 1 To rStr.Characters.Count
' c = rStr.Characters(i).Text 'debugging
' Debug.Print AscW(c) 'debugging
For j = 0 To 21
If ltrs(j) = rStr.Characters(i).Text Then
If j < 9 Then
sum = sum + j + 1
ElseIf j >= 9 And j < 19 Then
sum = sum + 10 * (j - 8)
ElseIf j >= 19 Then
sum = sum + 100 * (j - 17)
End If
End If
Next
Next
letterValue = sum
End Function
Sub testLetterValue()
Dim rStr As Range
Dim n As Long
Set rStr = ActiveDocument.Range
n = letterValue(rStr)
Debug.Print n
End Sub