0

I'm trying to count based on two criteria conditions being met using COUNTIFS. I can get it to work Im using one criteria but when I use two it throws an error "Expected: end of statement.

myworksheet.Cells(1, "A") = "HIGH"
myworksheet.Cells(1, "B") = "=COUNTIFS(" & otherworksheet.Name & "!A2:A" & LastRow & ",A1, & otherworksheet.Name & "B2:B" & LastRow & ","*bingo*")"
Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
infoseclearner1
  • 13
  • 1
  • 1
  • 4

1 Answers1

0

I think you got mixed up in all the quotation marks.

myworksheet.Cells(1, "B") = "=COUNTIFS(" & otherworksheet.Name & "!A2:A" & LastRow & ",A1," & otherworksheet.Name & "!B2:B" & LastRow & ",""*bingo*"")"

Added closing quotation marks after

",A1,

Also, to send quotation marks to excel, use double quotation marks. Like this:

",""*bingo*"")"

Also added ! here:

otherworksheet.Name & "!B2:B"

Also, if you are gonna use the cells command, why not use it with proper coordinates? Or why don't you just use the range command?

Cells(1, 1)

or

Range("A1")
vacip
  • 5,246
  • 2
  • 26
  • 54