Insert formula into a cell doesn't work :S

S

s80NL

If got this piece of code:

For x = 5 To 10
Range("D" & x).Formula = "=COUNTIF(PEN!$G:$G;$B" & x & " &
\"CO\")"
Next x

Should result in:
=COUNTIF(PEN!$G:$G;$B5 & "CO") in cell D5
...
=COUNTIF(PEN!$G:$G;$B10 & "CO") in cell D10

But it doesn't do the trick... someone who knows how to make it work?!
Thanks in advance!!

Steven
 
F

Franz Verga

s80NL said:
If got this piece of code:

For x = 5 To 10
Range("D" & x).Formula = "=COUNTIF(PEN!$G:$G;$B" & x & " &
\"CO\")"
Next x

Should result in:
=COUNTIF(PEN!$G:$G;$B5 & "CO") in cell D5
..
=COUNTIF(PEN!$G:$G;$B10 & "CO") in cell D10

But it doesn't do the trick... someone who knows how to make it work?!
Thanks in advance!!

Steven

Hi Steven,

try without the slash, so you will have:

Range("D" & x).Formula = "=COUNTIF(PEN!$G:$G;$B" & x & ""CO")"



--
Hope I helped you.

Thanks in advance for your feedback.

Ciao

Franz Verga from Italy
 
G

Guest

Sub a()
For x = 5 To 10
Range("D" & x).Formula = _
"=COUNTIF(PEN!$G:$G,$B" & x & "&""CO"")"
Next x

End Sub

Also, note that I use a comma instead of a semicolon. When you use Formula,
you should enter the formula using US English conventions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top