I have a short snippet of code that somebody else gave me to populate a combobox using unique values from a column.
However the values are times and are coming back as serial numbers. I would like to format them as times, so I tried changing it to:
Unfortunately, this throws up an error and I'm not sure why!
(Run-time error '457': This key is already associated wiht an element of this collection).
I also want to know, instead of specifying the last cell on the sheet, is there a way of specifying the last non-blank cell?
Thanks
Chris
Code:
With Sheets("Locations (Time Sheet)").Range("E2:E1048576")
v = .Value
End With
With CreateObject("scripting.dictionary")
.comparemode = 1
For Each e In v
If Not .exists(e) Then .Add e, Nothing
Next
If .Count Then cboEmployeeHours.List = Application.Transpose(.keys)
End With
However the values are times and are coming back as serial numbers. I would like to format them as times, so I tried changing it to:
Code:
If Not .exists(e) Then .Add Format(e, "h:mm"), Nothing
Unfortunately, this throws up an error and I'm not sure why!
(Run-time error '457': This key is already associated wiht an element of this collection).
I also want to know, instead of specifying the last cell on the sheet, is there a way of specifying the last non-blank cell?
Thanks
Chris