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 combination of random letters and numbers - an example

No question here, just a procedure example for the archive.

Insert a specified length of a random letter and number combination
into each cell in the selection

Sub RandomLetterNumberCombinations()

'Prompts for the length of a Random letter and number
'combination that is inserted into each cell in selection


Dim RandomLetOrNum, RanNumOrLetDecider As Integer
Dim c As Range
Dim FinalResult As String
Dim Length%
On Error Resume Next
Length = Application.InputBox(prompt:="What length would you like
the random letter/number

combination for each cell in selection?", Title:="Insert Random Letter
Number Combinations", _
Default:=1, Type:=1) 'type 1 is
number

If Length = False Then Exit Sub

For Each c In Selection
For i = 1 To Length

RanNumOrLetDecider = Int(Rnd * 2) 'decide whether number
or character
If RanNumOrLetDecider = 1 Then
RandomLetOrNum = Int(9 * Rnd())
End If
If RanNumOrLetDecider = 0 Then
RandomLetOrNum = Chr(Rnd() * 26 + 65)
End If
FinalResult = RandomLetOrNum & FinalResult
Next i

c.Value = FinalResult
''Reset the result to nothing for the next cell's calculation
FinalResult = ""
Next c
End Sub

search criteria:
random letter and number generator
random combination of letters and numbers
random numbers and letters in combination
combination random letters and numbers
insert random characters
return random combinations

 
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
Sort combination of letters and numbers Millabird New Users to Excel 2 June 6th 08 10:36 PM
How to? Create random letters and numbers in a cell Chris Excel Worksheet Functions 3 June 5th 08 08:04 AM
insert random letters into selection - an example procedure [email protected] Excel Programming 0 April 3rd 06 07:18 PM
random combination of letters rp Excel Worksheet Functions 1 September 16th 05 02:40 PM
how to insert numbers/letters in a chart vijay Charts and Charting in Excel 2 December 10th 04 09:45 PM


All times are GMT +1. The time now is 11:02 AM.

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"