Built on Excel 2013 (Windows), these two UDFs will not work (#VALUE error, among other strangeness) on Excel 2011 (Mac).
I am doing something somewhat simple: I am taking an input character, and converting it to another (special/extended) character one row displaced in a table using VBA. A dedicated sheet (called "KlattKey") has 2 columns with the possible inputs in column B, and desired outputs in column A. For example,
tʃ C
dʒ J
s s
ʃ S
z z
ʒ Z
The code works wonderfully (in Windows) using these two UDFs:
Public Function KlattToIPASingleCharacter(InputString As String) As String
Dim rngX As Range
Set rngX = Sheets("KlattKey").Range("B1:B200").Find(InputString, MatchCase:=True) 'find the character in column B
If Not rngX Is Nothing Then 'the character was found
KlattToIPASingleCharacter = rngX.Offset(0, -1).Text
Else 'the character was not found (error)
KlattToIPASingleCharacter = "%"
MsgBox Chr(34) & InputString & Chr(34) & " was not found to be a valid Klatt Character," & vbNewLine & _
Chr(34) & "%" & Chr(34) & " has been inserted in its place."
End If
End Function
Public Function KlattToIPA(InputString As String) As String
Dim Result As String
Dim i As Long
For i = 1 To Len(InputString)
Result = Result & KlattToIPASingleCharacter(Mid(InputString, i, 1)) 'iternate through every character and find the IPA equivalent
Next i
KlattToIPA = Result
End Function
Basically the "KlattToIPASingleCharacter" function does the conversion and "KlattToIPA" puts them together. By the way, if anyone has a suggestion on how to combine these two functions into one, I would love to hear it. I know it would be easy, but I just couldn't figure it out.
Also by the way, IPA stands for International Phonetic Alphabet (the special characters in column A), and Klatt is a more computer-typing-friendly system.
Bookmarks