quitethenovice
New Member
- Joined
- Jun 3, 2020
- Messages
- 12
- Office Version
- 365
Hello all
I'm using the VBA evaluate function to count matching rows. My question is about how to reference a value in an array. Is it a case of changing the way I declare the array or is there a way to index like I've tried?
Thanks!
PS. Below is an extract of the relevant parts of my module.
I'm using the VBA evaluate function to count matching rows. My question is about how to reference a value in an array. Is it a case of changing the way I declare the array or is there a way to index like I've tried?
Thanks!
PS. Below is an extract of the relevant parts of my module.
VBA Code:
Dim TechArray As Variant, AssetRng As String, Asset1 As String, Asset2 As String, Asset3 As String, LR1 As String
LR1 = ThisWorkbook.Sheets("Main").Range("A" & Rows.Count).End(xlUp).Row
TechArray = Array("John", "Bob", "Sandra", "Jason")
TechRng = "Q2:Q" & LR1
AssetRng = "E2:E" & LR1
Asset1 = """*sv*"""
Asset2 = """*s/v*"""
Asset3 = """*sluice*"""
Activeworkbook.Sheets("Fig").Range("G2").Value = ThisWorkbook.Sheets("Main").Evaluate("SUMPRODUCT(((ISNUMBER(SEARCH(" & Asset1 & "," & AssetRng & ")))" & _
"+(ISNUMBER(SEARCH(" & Asset2 & "," & AssetRng & ")))+(ISNUMBER(SEARCH(" & Asset3 & "," & AssetRng & "))))" & _
"*((ISNUMBER(SEARCH(" & TechArray(1) & "," & TechRng & ")))+(ISNUMBER(SEARCH(" & TechArray(4) & "," & TechRng & "))))"