Is it possible to choose which array to populate based on a variable name ?
I have 4 sets of data which belong to Yellow, Blue, Green and Lilac I have created 4 Arrays which are exactly the same. The data is the same except it has Y,B,G or L at the start and I want to populate the corresponding array, but don't want to create 4 sets of everything.
For i = 0 To UBound(myLines)
     myAlrmStrDate = Mid(myLines(i), 6, 2) & "/" & Mid(myLines(i), 4, 2) & "/" & Mid(myLines(i), 2, 2)
     myAlrmStrTime = Mid(myLines(i), 9, 2) & ":" & Mid(myLines(i), 11, 2) & ":" & Mid(myLines(i), 13, 2)
     myAlrmEndDate = Mid(myLines(i), 38, 2) & "/" & Mid(myLines(i), 36, 2) & "/" & Mid(myLines(i), 34, 2)
     myAlrmEndTime = Mid(myLines(i), 41, 2) & ":" & Mid(myLines(i), 43, 2) & ":" & Mid(myLines(i), 45, 2)
     myFaultDesc = (Mid(myLines(i), 49, 50))
     mySorter = (Mid(myLines(i), 53, 1))
        myCtime = CDate(myAlrmStrTime)
        myMinutes = Hour(myCtime) * 3600 + Minute(myCtime) * 60 + Second(myCtime)
        myftime = Int(myMinutes / 900) * 900
        myftime = myftime / 86400 * 96
  ' Find IOTT Alarms
     If InStr(1, (Mid(myLines(i), 49, 50)), "IOTT") And InStr(1, (Mid(myLines(i), 49, 50)), "CSC ack") <> 0 Then
        myTimeDiff = CDate(myAlrmEndTime) - CDate(myAlrmStrTime)
        mySorter(myftime).IOTT = mySorter(myftime).IOTT + 1
        mySorter(myftime).IOTTDUR = mySorter(myftime).IOTTDUR + myTimeDiff
        mySorter(96).IOTT = mySorter(96).IOTT + 1
          If mySorter(myftime).IOTT > mySorter(98).IOTT Then
            mySorter(97).IOTT = myftime
            mySorter(98).IOTT = mySorter(myftime).IOTT
          End If
       MsgBox "Line" & "=" & i & myFaultDesc
     End If
In the code above the line mySorter = (Mid(myLines(i), 53, 1)) selects the Y,B,G or L and it is this which I then want to set the Array to use to start populating the array.
Essentially I want it to point to the arrays below but don't want to create complicated if statements etc
Y(myftime).IOTTDUR
B(myftime).IOTTDUR
G(myftime).IOTTDUR
L(myftime).IOTTDUR
my Current Array is set up as follows
Type Sorter
     Date                As Date
     time                As Date
     Colour              As Long
     Area                As String
     Cart                As Long
     ISD                 As Long
     WNI                 As Long
     WNIDUR              As Date
     LM                  As Long
     IOTT                As Long
     IOTTDUR             As Date
     IOC                 As Long
End Type
Global Y() As Sorter
Global G() As Sorter
Global B() As Sorter
Global L() As Sorter
Global YGBL() As Sorter
ReDim Y(99)
ReDim G(99)
ReDim B(99)
ReDim L(99)
ReDim YGBL(99, 4)
The YGBL is an addition as suggested but still working on how this could work
Thanks
 
    