Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 441
Default Return a random letter

Thanks Tom. You've done it again!
I was not familiar with the "Asc" conversion.

"Tom Ogilvy" wrote:

So you could add another function that uses your existing function:

Public Function RandomLetter()
Dim argLow As Long, argHigh As Long
argLow = Asc("A")
argHigh = Asc("Z")
RandomLetter = Chr(RandomNumbers(argLow, argHigh))
End Function


Public Function RandomNumbers(argLow As Long, argHigh As Long) As Long

'RETURN A RANDOM NUMBER BETWEEN 'argLow' AND 'argHigh'
Randomize
RandomNumbers = CLng((argHigh - argLow) * Rnd + argLow)

End Function


from the immediate window:

? RandomLetter()
T


--
Regards,
Tom Ogilvy

"quartz" wrote in message
...
I have the following function which works great for returning a random
number in a range from a specified low to a specified high:

Public Function RandomNumbers(argLow As Long, argHigh As Long) As Long

'RETURN A RANDOM NUMBER BETWEEN 'argLow' AND 'argHigh'
Randomize
RandomNumbers = CLng((argHigh - argLow) * Rnd + argLow)

End Function

Now I need a similar function that would return a random letter between A
and Z. Can anyone suggest a more efficient method than just assigning all

the
letters of the alphabet to numbers between 1 and 26 to return a random

letter?

Thanks in advance.




Reply
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 Letter Generator Lost in Microbiology Excel Discussion (Misc queries) 4 October 8th 09 07:03 PM
random letter generation Ann Excel Worksheet Functions 5 May 30th 08 06:52 PM
how do I create random blocks of letter and words in excel? pencean Excel Worksheet Functions 1 January 19th 07 12:08 AM
Random letter and number generator Marie1uk Excel Worksheet Functions 4 January 23rd 06 06:04 PM
column header changed from letter to number, how return to letter Ron Excel Discussion (Misc queries) 2 May 9th 05 08:34 PM


All times are GMT +1. The time now is 01:14 AM.

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

About Us

"It's about Microsoft Excel"