Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default My ultimate goal is to create an ID that will always be unique

One way of making unique ID numbers:

Private Declare Function CoCreateGuid Lib "ole32" (id As Any) As Long

Function CreateGUID() As String

Dim btID(0 To 15) As Byte
Dim i As Long

If CoCreateGuid(btID(0)) = 0 Then
For i = 0 To 15
CreateGUID = CreateGUID + IIf(btID(i) < 16, "0", "") +
Hex$(btID(i))
Next
CreateGUID = Left$(CreateGUID, 8) & "-" & _
Mid$(CreateGUID, 9, 4) & "-" & _
Mid$(CreateGUID, 13, 4) & "-" & _
Mid$(CreateGUID, 17, 4) & "-" & _
Right$(CreateGUID, 12)
Else
CreateGUID = -1 'error result
End If

End Function


Sub test()

MsgBox CreateGUID()

End Sub


RBS


"Striker" wrote in message
...
My ultimate goal is to create an ID that will always be unique in column
"F". In that column I placed the following formula
=A2&""&B2&""&E2&""&C2.
I will need to do this on a daily basis, so would like to generate code to
do it for me at the push of a button. This can be any combination of
things. If you have a better idea to make a Unique ID column value, I'm
listening. However it MUST be unique even if the same data comes in
tomorrow, which is why I'm adding the date column.

(Spreadsheet Copy Attached) I also included a image of the sheet, in case
you're worried about a virus. Don't worry I changed all the numbers so
they
are not real numbers. This sheet is being passed to me, and I have to do
my
thing with it. I am currently even adding the date field and column
manually. So an added benefit would be to add that in code and make it a
text date like it is currently formatted so any leading "0" shows up.

My problem is the sheet can be up to 600 transactions, and I/I'm not sure
how to loop thru to find the last cell with good data.

So I'm Inserting a date column and populating with today's date as text
formatted as 051106
Inserting a UniqueID column and populating with a Unique ID down to the
last
cell with data (My problem, how to find the last cell with data when some
cells don't have data?)


Thanks for any help.








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
The ultimate Reference Guide to VBA in Excel Martin Knudsen Excel Programming 7 February 9th 06 09:24 AM
data reduction--goal:unique time data only ERC Excel Programming 6 February 2nd 06 11:34 PM
Ultimate protection shnim1 Excel Discussion (Misc queries) 1 October 18th 05 02:11 AM
Ultimate circular problem for chart creation nick g Excel Discussion (Misc queries) 1 July 26th 05 01:18 PM
How do I create a goal line on a bar chart? dragon4 Charts and Charting in Excel 2 December 30th 04 09:35 PM


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