A transient, virtual hobo, with only enough skill to be highly dangerous. You all know the type, as evidenced here:
The code I'm attaching, far below, does not work (shocker). It attempts to dynamically assign values to the properties? of my
variable (of type ProjectRegions) via a loop that feeds it the property name and the property value. Thus, 1st time
projectRegion.projectName = "Dismantle hampster wheel that is my job".
2nd time through:
projectRegion.projectNumber = "42".
3rd time through:
projectRegion.projectDescription = "A futile endeavor".
nth time through:
projectRegion.[regionName(n)] = regionValue(n)
I have two questions:
1. Is it possible to accomplish this dynamically, kind of like 'variable variables' in PHP?
2. I am currently using a Select Case, but it consumes hundreds of lines. Should I stick with that?
#1 would be funner and shorter. Thanks for any assistance.
Public Type ProjectRegions
projectName As Integer
projectNumber As String
projectDescription As String
Dim projectRegion As ProjectRegions
'Assume currentExcelRegion and currentExcelRegionValue change each time through the loop
For count = 1 To 1000
projectRegion = saveProjectRegions(currentExcelRegion, currentExcelRegionValue)
MsgBox "My project number is: " & projectRegion.projectNumber
MsgBox "My project description is: " & projectRegion.projectDescription
Public Function saveProjectRegions(regionName, regionValue) As ProjectRegions
projectRegion.[regionName] = regionValue 'This doesn't work, not that I expected it to
saveProjectRegions = projectRegion