Algorithm based on time and date ( =Now() )

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All

I need to create an algorithm based on time and date i.e =now(), and have this in a vba macro, so i can run it via a button
I've never done an algorithm before, so i dont know how to begin
The macro part i should be able to do ok

Can anyone suggest a way to build a basic algorithm, or point me towards a url

Thanks in advance
P
 
An algorithm is a set of rules.

What do you want the algorithm to do???

--

Vasant



Phillip Torna. said:
Hi All,

I need to create an algorithm based on time and date i.e =now(), and have
this in a vba macro, so i can run it via a button.
 
I need it to produce a 22 digit unique number. (though i may need to be produce either smaller or larger numbers depending on the current projects needs.
As time and date are unique, i though an algorithm based on time & date would be able to provide this

Cheers
PT
 
You're limited to 15 digits with a floating point number,
so you will probably be wanting to construct a string
with your unique ID.

Dim UniqueID As String
UniqueID="Q1234567" & Format(Date,"yyyymmdd") & Format
(Time,"hhmmss")
 
Thank's Brad
I'll be able to construct something using your below example and some existing code

Thanks. Very much appreciated

----- Brad Yundt wrote: ----

You're limited to 15 digits with a floating point number,
so you will probably be wanting to construct a string
with your unique ID

Dim UniqueID As Strin
UniqueID="Q1234567" & Format(Date,"yyyymmdd") & Forma
(Time,"hhmmss"
 
Phillip Torna said:
I'll be able to construct something using your below example and some
existing code. ....
----- Brad Yundt wrote: ----- ....
UniqueID="Q1234567" & Format(Date,"yyyymmdd") & Format(Time,"hhmmss")

If only one person would be using this, this would be OK. If multiple users
could be using this at the same time, there's a nonnegligible chance your
code could generate multiple instances of the exact same 'unique' key.

There's only one reliable way to generate unique serial numbers: request
them from a single, central source that keeps track of the last such value
provided. No other approach is robust.
 
GUIDs?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Bob Phillips said:
....

Yes, for example. Banks and other high transaction count businesses also
have localized batching of IDs, in which local servers receive a batch of
IDs from a central machines. Those IDs are marked as distributed but not yet
used until those local machines replicate with the central machine and
transmit the IDs actually assigned. Depending on how many distributed but
not yet assigned IDs there are on the local server, the central machine may
or may not give the server another batch.

What I'm getting at is that real time centralization isn't necessary, but
eventual centralization during replication is necessary. Use the level of
centralization or localization that works best. Just don't forget to
replicate.
 
Hi Harlan

At present, it is intended for the workbook this is going into, only one person will be given access to at any given time
I've been able to create a few algorithms/functions that will be used together to create a unique id, so this should greatly reduce any chance of a duplicate

To ensure that only one person can use it at a time, i've created a little macro that checks to see if the workbook is currently open, and if so, it gives the user a little message, and closes the workbook. Plus, i've included as much protection as possible with-in excel

Thanks for you input about the multi-users. It made me think that little bit more about generating non-unique id's

Thanks
PT.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top