StrawberryDreams
Board Regular
- Joined
- Mar 26, 2022
- Messages
- 79
- Office Version
- 365
- Platform
- Windows
- MacOS
- Mobile
I've built a table that converts the value based on the Original Unit and the Converted to Unit. The New cell value relies on another table that has the multiple possibilities and results that are used to pull from using index match.
The Element table allows the user to select an Element and its Value. As it stands everything works but I don't know how to expand the Element table to do another conversion for another element without getting a spill error ( Convert Table would have to have each of the 9 possible formula results written for each possible Element Name). I could do that but would like to learn if there is a better more elegant way to do this even in VBA if that makes it easier ?
The Element table allows the user to select an Element and its Value. As it stands everything works but I don't know how to expand the Element table to do another conversion for another element without getting a spill error ( Convert Table would have to have each of the 9 possible formula results written for each possible Element Name). I could do that but would like to learn if there is a better more elegant way to do this even in VBA if that makes it easier ?
Basic data calculator test 9.9b.xlsm | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | |||
1 | Original Unit | Element | Atomic Weight | Valence | mmol/L = ppm / atomic weight | ||||||||
2 | mmol/L | N | 14 | 1 | meq/L = ppm * Valence / Atomic Weight | ||||||||
3 | Convert to Unit | Ca | 30 | 2 | ppm = meq/L * Atomic Weight / Valence | ||||||||
4 | meq/L | ||||||||||||
5 | Convert Table | ||||||||||||
6 | Element Choosen | Original Unit | Convert to Unit | New Value Result | Convert formulas for New Value Result | ||||||||
7 | Ca | ppm | ppm | 120 | No conversion needed - Units match | ||||||||
8 | Element | Value | New Value | Ca | ppm | mmol/L | 4 | mmol/L = Cell Value * Atomic weight | |||||
9 | Ca | 120 | 240 | Ca | ppm | meq/L | 8 | meq/L = (Cell Value * Valence) / Atomic Weight | |||||
10 | |||||||||||||
11 | Ca | mmol/L | mmol/L | 120 | No conversion needed - Units match | ||||||||
12 | Ca | mmol/L | ppm | 3600 | ppm = Cell Value * Atomic Weight | ||||||||
13 | Ca | mmol/L | meq/L | 240 | meq/L = Cell Value * Valence | ||||||||
14 | |||||||||||||
15 | Ca | meq/L | meq/L | 120 | No conversion needed - Units match | ||||||||
16 | Ca | meq/L | ppm | 1800 | ppm = Cell Value * Atomic Weight / Valence | ||||||||
17 | Ca | meq/L | mmol/L | 60 | mmol/L = Cell Value / Valence | ||||||||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
C9 | C9 | =INDEX(Table26[New Value Result],MATCH(1,(Table26[Original Unit]=A2)*(Table26[Convert to Unit]=A4),0)) |
F7:F8,F15:F17,F11:F13 | F7 | =Table24[Element] |
F9 | F9 | =Table24[@Element] |
I7,I15,I11 | I7 | =Table24[Value] |
I8 | I8 | =Table24[Value] / INDEX(Table25[Atomic Weight],MATCH(Table24[Element],Table25[Element],0)) |
I9 | I9 | =Table24[Value] * INDEX(Table25[Valence],MATCH(Table24[@Element],Table25[Element],0)) / (INDEX(Table25[Atomic Weight],MATCH(Table24[Element],Table25[Element],0))) |
K11,K15 | K11 | =K7 |
I12 | I12 | =Table24[Value]* INDEX(Table25[Atomic Weight],MATCH(Table24[Element],Table25[Element],0)) |
I13 | I13 | =Table24[Value] * INDEX(Table25[Valence],MATCH(Table24[Element],Table25[Element],0)) |
I16 | I16 | =Table24[Value] * INDEX(Table25[Atomic Weight],MATCH(Table24[Element],Table25[Element],0)) / INDEX(Table25[Valence],MATCH(Table24[Element],Table25[Element],0)) |
I17 | I17 | =Table24[Value] / INDEX(Table25[Valence],MATCH(Table24[Element],Table25[Element],0)) |
Cells with Data Validation | ||
---|---|---|
Cell | Allow | Criteria |
A4:A5 | List | ppm, mmol/L, meq/L |
A2 | List | ppm, mmol/L, meq/L |
A9 | List | N,Ca |