KlayontKress
Board Regular
- Joined
- Jan 20, 2016
- Messages
- 67
- Office Version
- 2016
- Platform
- Windows
I'm looking to modify a VBA code to create a unique date and time stamp. The code I have so far is
This gives me the integer value of the date but I also need the time because the macro I'm using will go to the next line and create a route id for the next person and Ineed unique values across days. Right now, the existing code
is generating "Random" numbers that are repeating day to day and this is messing up the scheduling program because it's trying to add what is supposed to be a new day's route information to a past day's route because the route id's are the same. I found the code that was generating this number and had the idea of using the date time stamp to generate a unique number number but I lack the knowledge on how to get the date and time together in an integer.
The code to generate this route id repeats until it creates a unique route id for all of the service techs that day so I need it to pull the current system time to a fraction of a second (a millisecond may work) so that if it can process multiple times in a single second, each entry is unique from the others.
Any help is greatly appreciated.
Thanks,
Code:
Sheets("Route Import").Cells(x, 1).Value = Int(CDbl(Now()))
This gives me the integer value of the date but I also need the time because the macro I'm using will go to the next line and create a route id for the next person and Ineed unique values across days. Right now, the existing code
Code:
Sheets("Route Import").Cells(x, 1).Value = Round(((999 - 100 + 1) * Rnd + 100), 0) & Round(((999 - 10 + 1) * Rnd + 100), 0) & Round(((999 - 10 + 1) * Rnd + 100), 0)
The code to generate this route id repeats until it creates a unique route id for all of the service techs that day so I need it to pull the current system time to a fraction of a second (a millisecond may work) so that if it can process multiple times in a single second, each entry is unique from the others.
Any help is greatly appreciated.
Thanks,
Last edited: