You are quite right my code shows just how inept at this I really am. Hopefully I will be able to refine the code as I improve.
what I am trying to do is track traffic flow across a number of data collection points.
Somewhat inelegantly I have got it all working (too much code to place it all here) except that when I pass time from the original spreadsheets through my code via arrays and place it on the new sheet I lose the hh:mm format and end up with time serials .
I can reformat on the final sheet but it takes quite some time to select the cells because they are spread throughout the final sheet.
If I can find out how to format in VBA I could include the code somewhere in one of the numerous sub routines. Youre original suggestion appeared to be along the right lines but my lack of knowledge in adapting the code produced a syntax error, something about incorrect or missing object.
Thank you for taking both the time (no pun intended) and effort to look at this.
Part of the code that sorts the routes and places the masterpoints list on the spreadsheet sheet is shown below Column 1 of the masterpointslist contains the time that loses format during its travel.
Public Sub ROUTETABLE(oldarr)
Dim match As Boolean
Dim Ri As Long
Dim i As Long
Dim Cm As Integer
Dim newarr() As Variant
Dim newrows As Long
Dim newcols As Integer
Dim newCells As Range
match = False
Ri = 1
Cm = 3
ReDim newarr(UBound(oldarr, 1) * 2, 32)
For i = 1 To UBound(oldarr, 1) - 1
'TRAP debugging
'If i = UBound(oldarr, 1) - 1 Then
'MsgBox ("check sub trap and REDIM newarr")
'End If
If match = False Then
Cm = 3
newarr(Ri, 1) = oldarr(i, 3)
newarr(Ri, 2) = oldarr(i, 2)
newarr(Ri, 3) = oldarr(i, 4)
newarr(Ri + 1, 3) = oldarr(i, 1)
Else
newarr(Ri, Cm) = oldarr(i, 4)
newarr(Ri + 1, Cm) = oldarr(i, 1)
End If
If oldarr(i, 3) = oldarr(i + 1, 3) And oldarr(i, 3) <> "" Then
match = True
Cm = Cm + 1
Else
'TRAP 2 debugging
'If Ri > 4500 Then
'MsgBox ("check" & Ri)
'End If
Ri = Ri + 2
match = False
End If
Public Sub MASTERLISTTOSHEET()
Dim masterrows As Integer
Dim mastercols As Integer
Dim ArrayCells As Range
Dim x As Variant
masterrows = UBound(masterpointslist, 1)
mastercols = UBound(masterpointslist, 2)
Worksheets("MASTERPOINTSLIST").Activate
Worksheets("MASTERPOINTSLIST").Range("a2").Select
Set ArrayCells = ActiveCell.Range(Cells(1, 1), Cells(masterrows, mastercols))
MsgBox ActiveSheet.Name
x = ActiveSheet.Range(Cells(1, 1), Cells(masterrows, mastercols))
ActiveSheet.Range(Cells(1, 1), Cells(masterrows, mastercols)).Select
ArrayCells.Value = masterpointslist
'Worksheets("MASTERPOINTSLIST").Range(Cells(2, 1), Cells(masterrows, mastercols)).Value = masterpointslist
End Sub
Bookmarks