PDA

View Full Version : [SOLVED] Referencing a range into formula: explanation



Edmond
02-15-2019, 08:08 AM
Hello everyone,

I was trying to get a range into a formula:


Cells(1, 11).Formula = "=COUNTIF(" & Countif.Address & ",J1)"

I have found the solution while browsing on google.
However, I don't understand why the typo has to be as herein-above.

Would you have some explanation about the "{Space}" and the "&"? I tried to find some explanations online but didn't find anything...

Thanks in advance for your time and help.

Paul_Hossler
02-15-2019, 11:53 AM
.Formula is looking for a string that equates to a 'worksheet formula'

Assuming that Countif is a range variable, say column A, then it has a .Address of "A:A"

The string that is generated is

"=COUNTIF(A:A,J1)"

and so K1 has the formula


=COUNTIF(A:A,J1) in it

Edmond
02-18-2019, 10:27 AM
As usual, thanks a lot Paul!