I have a column of date and times like so :
I have a collection that loops through all 527,000 rows to collect all these times. First time I tried, I noticed that it was only holding the date :
so I added Cstr hoping it would work to save it as a string :
I can see that this is holding the data but when I try to search for the index of one, it always says tchange = string date (good), tReturn = -1 :
The above code is looping through another group of date times (below) and I'm trying to get it to search the date time from the source (t) in the collection of date times, find the index, then with that index and the index of the employee number put specific data in the cell and drag it down to the corresponding date time from the I column. The destination sheet looks like the above screen shot and the source data looks like below :
If someone could point out where I'm failing with the collection I would appreciate it.
I have a collection that loops through all 527,000 rows to collect all these times. First time I tried, I noticed that it was only holding the date :
VBA Code:
For Each DDateRng In Destws.Range("A2:A" & DestLRow)
Timecoll.Add Destws.Cells(DDateRng.Row, 1).Value
Next DDateRng
so I added Cstr hoping it would work to save it as a string :
VBA Code:
For Each DDateRng In Destws.Range("A2:A" & DestLRow)
Timecoll.Add CStr(Destws.Cells(DDateRng.Row, 1).Value)
Next DDateRng
I can see that this is holding the data but when I try to search for the index of one, it always says tchange = string date (good), tReturn = -1 :
VBA Code:
For Each t In Sourcews.Range("H2:H" & SourceLRow)
tchange = CStr(t.Value)
tReturn = Timecoll.indexof(tchange, 0)
eReturn = SEmpcoll.indexof(t.Offset(0, -6).Value, 0)
If tReturn = -1 Then
'do something?
Else
Destws.Cells(tReturn, eReturn).Value = t.Offset(0, 4).Value
End If
The above code is looping through another group of date times (below) and I'm trying to get it to search the date time from the source (t) in the collection of date times, find the index, then with that index and the index of the employee number put specific data in the cell and drag it down to the corresponding date time from the I column. The destination sheet looks like the above screen shot and the source data looks like below :
If someone could point out where I'm failing with the collection I would appreciate it.