r/excel • u/man-teiv 226 • Feb 13 '18
User Defined Function I've made the =NATO() function, converting any given string into Nato phonetic alphabet!
I was wondering if such a thing existed and I realized I needed it in my life. I'm sure there are thousands of ways to improve it, so feel free to correct me on it! (EDIT: a much better version is shown in the comments)
Option Explicit
Function NATO(command As String)
Dim i#
Dim word As String
NATO = ""
For i = 1 To Len(command)
Select Case LCase(Mid(command, i, 1))
Case " "
word = ""
Case "a"
word = "Alfa"
Case "b"
word = "Bravo"
Case "c"
word = "Charlie"
Case "d"
word = "Delta"
Case "e"
word = "Echo"
Case "f"
word = "Foxtrot"
Case "g"
word = "Golf"
Case "h"
word = "Hotel"
Case "i"
word = "India"
Case "j"
word = "Juliett"
Case "k"
word = "Kilo"
Case "l"
word = "Lima"
Case "m"
word = "Mike"
Case "n"
word = "November"
Case "o"
word = "Oscar"
Case "p"
word = "Papa"
Case "q"
word = "Quebec"
Case "r"
word = "Romeo"
Case "s"
word = "Sierra"
Case "t"
word = "Tango"
Case "u"
word = "Uniform"
Case "v"
word = "Victor"
Case "w"
word = "Whiskey"
Case "x"
word = "X-ray"
Case "y"
word = "Yankee"
Case "z"
word = "Zulu"
End Select
NATO = NATO & word & " "
Next i
End Function
131
Upvotes
View all comments
27
u/pancak3d 1189 Feb 13 '18 edited Feb 13 '18
Nice. There are ways to make the code shorter and more efficient, sure, but this approach is perfectly good for the application and well written!