Bluefox
05-08-2023, 07:50 AM
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.
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 & "*")
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.
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 & "*")