JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,687
- Office Version
- 365
- Platform
- Windows
I am working on a macro that will calculate overall product ratings based on my ratings of various properties of the products that are available. I am in the market for an electric car, so I thought it would be a good test.
Most of the EV properties are numerical, such as price, miles/kWh, range, horsepower, headroom, and legroom. For numerical properties, all I need is to know whether higher numbers are better (range, headroom, star ratings), or lower numbers are (price, availability, rankings).
Several properties are not numerical, like body style (sedan, SUV, ...) and drive (4WD, AWD, RWD, FWD). And some numerical properties, like number of doors, are not linear. For properties that are not numerical and linear, I create "helper" tables that convert the options to linear (and proportional) numbers. Here are a few examples:
The macro will use these tables to convert non-numerical and non-linear values to linear numerical values that can be aggregated with the other properties.
The problem is how to handle these in the macro. The names of the tables are not fixed so I can't declare them. I need some sort of dynamically variable way of accessing the tables. It is my understanding that VBA supports arrays of arrays (also called "jagged" arrays). Can I declare a jagged array then load these tables into it? I have never done this before, so before I try it, I thought I'd ask if this is the way to go or if there is a better way. I would appreciate any hints or tips on how to do it.
Thanks
Most of the EV properties are numerical, such as price, miles/kWh, range, horsepower, headroom, and legroom. For numerical properties, all I need is to know whether higher numbers are better (range, headroom, star ratings), or lower numbers are (price, availability, rankings).
Several properties are not numerical, like body style (sedan, SUV, ...) and drive (4WD, AWD, RWD, FWD). And some numerical properties, like number of doors, are not linear. For properties that are not numerical and linear, I create "helper" tables that convert the options to linear (and proportional) numbers. Here are a few examples:
Weighted Ratings.xlsm | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
B | C | D | E | F | G | H | I | J | K | L | M | |||
4 | Body Type | Rtg | Comments | Drive | Rtg | Heater | Rtg | Doors | Rtg | |||||
5 | Sedan | 10 | 4 doors, traditional trunk | 4WD | 5 | Heat Pump | 3 | 5 | 5 | |||||
6 | SUV | 7 | AWD | 4 | Resistive | 1 | 6+ | 4 | ||||||
7 | MPV | 7 | Multi-purpose vehicle | RWD | 3 | 4 | 2 | |||||||
8 | Hatch | 7 | Hatchback | FWD | 1 | 2 | 0 | |||||||
EV Tables |
The macro will use these tables to convert non-numerical and non-linear values to linear numerical values that can be aggregated with the other properties.
The problem is how to handle these in the macro. The names of the tables are not fixed so I can't declare them. I need some sort of dynamically variable way of accessing the tables. It is my understanding that VBA supports arrays of arrays (also called "jagged" arrays). Can I declare a jagged array then load these tables into it? I have never done this before, so before I try it, I thought I'd ask if this is the way to go or if there is a better way. I would appreciate any hints or tips on how to do it.
Thanks