Hey guys,
The other day I was playing around and thought it might be fun to try and build a word descrambler in Excel using VBA. Most places online tend to use C++ or some scripting language to run this sort of code.
My thought was to store the list of possible words in a spreadsheet. Below is the code I currently have written. I'm somewhat stuck as to how to write the algorithm to work for an input word of any length. If I set a limit on the length of the word, the code is simple. But how can it work with an unknown word length? Any thoughts?
Note that some of the code is simply testing the command within the intented context (ie the checkspelling command) and not the actual implementation of the command. My code is in the very early stages.
Thanks,
BD
The other day I was playing around and thought it might be fun to try and build a word descrambler in Excel using VBA. Most places online tend to use C++ or some scripting language to run this sort of code.
My thought was to store the list of possible words in a spreadsheet. Below is the code I currently have written. I'm somewhat stuck as to how to write the algorithm to work for an input word of any length. If I set a limit on the length of the word, the code is simple. But how can it work with an unknown word length? Any thoughts?
Note that some of the code is simply testing the command within the intented context (ie the checkspelling command) and not the actual implementation of the command. My code is in the very early stages.
Code:
Sub WordGen()
Dim strWord As String, lenWord As Integer, count As Integer, isWord As Boolean
Dim lArray()
'Set variables
strWord = InputBox("Input word or letters to be descrambled.", "Word Descrambler")
lenWord = Len(strWord)
ReDim lArray(lenWord - 1)
ThisWorkbook.Sheets(1).Range("A2").Value = strWord
'Loop through letters to fill array
For i = 0 To lenWord - 1
lArray(i) = LCase(Right(Left(strWord, i + 1), 1))
Next
iLet = LCase(Right(Left(strWord, i), 1))
Application.DisplayAlerts = False
isWord = ThisWorkbook.Sheets(1).Range("A2").CheckSpelling
Application.DisplayAlerts = True
End Sub
Thanks,
BD