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: 220
Default Fast way to generate unique strings

what is the fastest VBA code to generate a list of random strings of a
specified length.

the function prototype i want is

sub GetUniqueStrings(Strings() as string, Length as long)


The one i had been using seems slow when using it to generate lots of
strings, and i was wondering if there was a way to speed it up. Thanks!




Public Function GetUniqueString(ByVal NumChars As Long) As String
Dim i As Long, str As String

GetUniqueString = Space$(NumChars)

For i = 1 To NumChars
Mid$(GetUniqueString, i, 1) = Chr(RandBetween(97, 122))
Next i

End Function

Public Function RandBetween(ByVal LB As Long, ByVal UB As Long) As Long
RandBetween = LB + Round(Rnd * (UB - LB), 0)
End Function
 
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
how do I generate a unique reference number??? Rachel Excel Discussion (Misc queries) 3 November 21st 08 03:56 AM
generate unique random numbers Stephen Larivee New Users to Excel 7 March 29th 06 01:04 AM
Fast way to search many cells by column for text strings Mikee Excel Discussion (Misc queries) 2 July 1st 05 06:44 PM
counting unique strings Sparky Mark Excel Discussion (Misc queries) 3 January 20th 05 11:47 PM
Automatically Generate a unique file name... Ian L Excel Programming 3 July 15th 03 02:08 AM


All times are GMT +1. The time now is 01:53 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"