Skip to content

Instantly share code, notes, and snippets.

@markshust
Created June 21, 2013 16:43
Show Gist options
  • Select an option

  • Save markshust/5832535 to your computer and use it in GitHub Desktop.

Select an option

Save markshust/5832535 to your computer and use it in GitHub Desktop.
Excel Macro to create 30-char alphanumeric strings and insert into currently selected cells
Sub createRandstring30()
Set MyRange = Selection
Dim randstring As String
Dim i As Integer
For Each mycell In MyRange
randstring = ""
Randomize
For i = 1 To 30
If Int((2 * Rnd) + 1) = 1 Then
randstring = randstring & Chr(Int(26 * Rnd + 65))
Else
randstring = randstring & Int(10 * Rnd)
End If
Next i
mycell.Value = randstring
Next mycell
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment