Vaibhav Miglani
Vaibhav Miglani

Reputation: 33

Transfer formula value to variable

Code: VBA

Sheets("Facebook").Activate

catcount(1) = Application.WorksheetFunction.CountIf(cndtnltrnsfr.Col_Letter(posval(1)) & "2:" & cndtnltrnsfr.Col_Letter(posval(1)) & emptyRow & "," & chr(34) & cat(1) & chr(34))

MsgBox catcount(1)

catcount(1) : an array in which the number of times a category is occurring is stored

posval(1) : an array which stores the position of a specific value

cat(1) : category

It is giving an error

Argument not optional!

and highlighting .Countif.

Upvotes: 0

Views: 42

Answers (1)

Thomas G
Thomas G

Reputation: 10226

The WorksheetFunction.CountIf method takes 2 arguments and you only have one in this long concatenation :

cndtnltrnsfr.Col_Letter(posval(1)) & "2:" & cndtnltrnsfr.Col_Letter(posval(1)) & emptyRow & "," & chr(34) & cat(1) & chr(34)

Maybe you should change this :

& "," &

to this :

,

I can't answer more with what you have asked and shown.

Upvotes: 1

Related Questions