Hello together,
please help me to extend my VBA code to highlight amount of cells (top to bottom) for a certain year based on how many tools are planned in separate table on the right side in attached "example".
So far i wrote code that only counts tools for first country, but i dont know how to bind it to value from another table.
For example in USA it is planned to have 2 cutting tools in 2023 so for 2 cutting tools must be highlighted 2 cells in col. C
thank you in advance, i am totally new to vba.
please help me to extend my VBA code to highlight amount of cells (top to bottom) for a certain year based on how many tools are planned in separate table on the right side in attached "example".
So far i wrote code that only counts tools for first country, but i dont know how to bind it to value from another table.
For example in USA it is planned to have 2 cutting tools in 2023 so for 2 cutting tools must be highlighted 2 cells in col. C
thank you in advance, i am totally new to vba.
VBA Code:
Dim rng1, rng2 As Range
Dim criteria1, criteria2 As Variant
Dim result As Double
Set rng1 = Range("A2:A14")
criteria1 = "USA"
Set rng2 = Range("B2:B14")
criteria2 = "Cutting tool"
result = WorksheetFunction.CountIfs(rng1, "*" & criteria1 & "*", rng2, "*" & criteria2 & "*")
DEVELOPER.xlsm | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | |||
1 | Country | Category | 2023 | 2024 | 2025 | 2026 | 2027 | 2023 | 2024 | 2025 | 2026 | 2027 | ||||||||
2 | USA | Cutting tool | USA | Cutting tool | 2 | 3 | 2 | 4 | 5 | |||||||||||
3 | USA | Cutting tool | Europe | Cutting tool | 1 | 3 | 2 | 2 | 1 | |||||||||||
4 | USA | Cutting tool | ||||||||||||||||||
5 | USA | Cutting tool | ||||||||||||||||||
6 | USA | Cutting tool | ||||||||||||||||||
7 | USA | Cutting tool | ||||||||||||||||||
8 | Europe | Cutting tool | ||||||||||||||||||
9 | Europe | Cutting tool | ||||||||||||||||||
10 | Europe | Cutting tool | ||||||||||||||||||
11 | Europe | Cutting tool | ||||||||||||||||||
12 | Europe | Cutting tool | ||||||||||||||||||
13 | Europe | Cutting tool | ||||||||||||||||||
14 | Europe | Cutting tool | ||||||||||||||||||
15 | ||||||||||||||||||||
16 | ||||||||||||||||||||
Sheet3 |
Cells with Conditional Formatting | ||||
---|---|---|---|---|
Cell | Condition | Cell Format | Stop If True | |
M1:Q1 | Cell | contains a blank value | text | NO |
C1:G1 | Cell | contains a blank value | text | NO |