Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Apologies in advance, I am NOT a coder, I am trying to fix VBA someone wrote
for me by 'slogging' through it on my own. Making some decent headway on easier stuff but I am at an impasse. He has a function that creates an Acronym out of a Value. However I want to modify it so it ONLY does it if the # of words in that value 1. Can anyone give me a heads up on how to add that here please? It would be most appreciated: Private Function GenerateAcronym(ByVal val As String) As String 'Tested OK Dim str As String, prom As String, ch As String, res As String Dim pos As Long res = "" str = Trim(val) If Len(str) 0 Then While InStr(str, " ") 1 prom = Trim(Left(str, InStr(str, " ") - 1)) If Not (UCase(prom) = "OF") And Not (UCase(prom) = "FOR") And Not (UCase(prom) = "THE") And _ Not (UCase(prom) = "AND") And Not (UCase(prom) = "A") Then ch = Left(prom, 1) If (Asc(ch) = 65 And Asc(ch) <= 90) Or (Asc(ch) = 97 And Asc(ch) <= 122) Then res = res + Left(prom, 1) End If End If str = Trim(Right(str, Len(str) - InStr(str, " "))) 'res = res + Left(str, 1) Wend prom = str If Not (UCase(prom) = "OF") And Not (UCase(prom) = "FOR") And Not (UCase(prom) = "THE") And _ Not (UCase(prom) = "AND") And Not (UCase(prom) = "A") Then ch = Left(prom, 1) If (Asc(ch) = 65 And Asc(ch) <= 90) Or (Asc(ch) = 97 And Asc(ch) <= 122) Then res = res + Left(prom, 1) End If End If End If GenerateAcronym = UCase(res) End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Spell check flagging words I can't find in Excel | Excel Discussion (Misc queries) | |||
Can I highlight misspelt words in cells when I use the spell check | Excel Discussion (Misc queries) | |||
Turn numbers into words to automate check-writing | Excel Discussion (Misc queries) | |||
Turn numbers into words to automate check-writing | Excel Discussion (Misc queries) | |||
Can I have spell check ignore errors and alert me to real words? | Excel Discussion (Misc queries) |