LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default insert random letters into selection - an example procedure

no question here, just an example procedure for the archive.

Prompts user for the number of random letters to be inserted into each
cell
in the active selection. The procedure seems to be limited to up to 39
random
letters per cell.

Sub RandomLETTERSGenerator()

'Prompts for the number of Random letters for each cell in selection
'Seems to be limited to up to 39 random letters per cell
On Error Resume Next
Dim LetterNum%
Dim RanBaseLetter, RanAddLetter, RanAllLetters As String
RanBaseLetter = "CHAR(TRUNC(RAND()*26+65))"
RanAddLetter = "&CHAR(TRUNC(RAND()*26+65))"

LetterNum = Application.InputBox(prompt:="How many random letters
do you want in each cell in selection?", Title:="Insert Random
Letter(s)", _
Default:=1, Type:=1) 'type 1 is
number

If LetterNum = False Then Exit Sub

If LetterNum = 1 Then
Selection.FormulaR1C1 = "=" & RanBaseLetter
End If

If LetterNum 1 Then

For i = 1 To LetterNum - 1
RanAllLetters = RanAddLetter & RanAllLetters
Next i

Selection.FormulaR1C1 = "=" & RanBaseLetter & RanAllLetters

End If

'Paste value the formulas
Selection.Value = Selection.Value

End Sub

return random letters
insert random letters
generate random letters
random letter generator
prompt for random letter(s) insertion

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
random combination of letters rp Excel Worksheet Functions 1 September 16th 05 02:40 PM
return random letters - an example [email protected] Excel Programming 1 August 31st 05 01:27 PM
trying to find random drive letters VBAfunkymonk Excel Programming 2 February 11th 05 10:45 AM
Display sum of selection with SelectionChange procedure Herman[_4_] Excel Programming 3 August 16th 04 01:42 PM


All times are GMT +1. The time now is 04:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"