Created
February 8, 2022 08:50
-
-
Save palikhov/c6be257795716613943668737f8fb9ad to your computer and use it in GitHub Desktop.
primitive macro to dice formula excel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub DiceXlator() | |
Dim r As Range, v As String, NewForm As String, deemode As Boolean | |
Dim dee As String | |
dee = "d" | |
deemode = False | |
For Each r In Selection | |
v = r.Value | |
NewForm = "=" | |
For i = 1 To Len(v) | |
ch = Mid(v, i, 1) | |
If ch = dee Then | |
NewForm = NewForm & "*RANDBETWEEN(1," | |
deemode = True | |
Else | |
If Not IsNumeric(ch) And deemode Then | |
deemode = False | |
NewForm = NewForm & ")" | |
End If | |
NewForm = NewForm & ch | |
End If | |
Next i | |
If deemode Then | |
NewForm = NewForm & ")" | |
End If | |
r.Offset(0, 1).Formula = NewForm | |
Next r | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment