Hi. I have a table listobject in my spreadsheet called TableSource. It has six columns called SheetNum, Name, Table, Depot, Area, and FieldSource.
In my VBA I have a type class
Type ChosenData
name As String
table As String
depot As String
area As String
fieldSource As String
End Type
Is there an easy way to run a sub that will cycle through all rows in TableSource and add the data to an array of the ChosenData type.
This is what I have so far:
Dim workings As Worksheet
Set workings = ActiveWorkbook.Worksheets("workings")
Dim myData(2) As ChosenData
With workings
myData(0).name = .Range("C4")
myData(1).name = .Range("C5")
myData(2).name = .Range("C6")
myData(0).table = .Range("D4")
myData(1).table = .Range("D5")
myData(2).table = .Range("D6")
myData(0).depot = .Range("E4")
myData(1).depot = .Range("E5")
myData(2).depot = .Range("E6")
myData(0).area = .Range("F4")
myData(1).area = .Range("F5")
myData(2).area = .Range("F6")
myData(0).fieldSource = .Range("G4")
myData(1).fieldSource = .Range("G5")
myData(2).fieldSource = .Range("G6")
End With
The table starts on B3, and only has 3 records. But if I wanted to add a 4th or more, I'd have to edit the code. What's the best way to add all rows to my array type so I won't have to worry about changing the code
Bookmarks