ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   return random letters - an example (https://www.excelbanter.com/excel-programming/338739-return-random-letters-example.html)

[email protected]

return random letters - an example
 
No question here just a procedure for the archive.

Return a random letter for each cell in selection

Sub RandomLetterGenerator()

'Returns a random letter in each cell in selection
On Error Resume Next
Selection.FormulaR1C1 = "=CHAR(TRUNC(RAND()*26+65))"

'Paste value the formulas

Selection.Copy

Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False

End Sub

search criteria
return random letters
insert random letters
generate random letters


Bernie Deitrick

return random letters - an example
 
Just so that this doesn't appear unanswered, one comment: no need for the pastespecial:

Sub RandomLetterGenerator2()
'Returns a random letter in each cell in selection
Selection.FormulaR1C1 = "=CHAR(TRUNC(RAND()*26+65))"
Selection.Value = Selection.Value
End Sub

HTH,
Bernie
MS Excel MVP


wrote in message
oups.com...
No question here just a procedure for the archive.

Return a random letter for each cell in selection

Sub RandomLetterGenerator()

'Returns a random letter in each cell in selection
On Error Resume Next
Selection.FormulaR1C1 = "=CHAR(TRUNC(RAND()*26+65))"

'Paste value the formulas

Selection.Copy

Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False

End Sub

search criteria
return random letters
insert random letters
generate random letters





All times are GMT +1. The time now is 02:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com