ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Insert formula into a cell doesn't work :S (https://www.excelbanter.com/excel-programming/370683-insert-formula-into-cell-doesnt-work-s.html)

s80NL[_12_]

Insert formula into a cell doesn't work :S
 

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


--
s80NL


------------------------------------------------------------------------
s80NL's Profile: http://www.excelforum.com/member.php...o&userid=36374
View this thread: http://www.excelforum.com/showthread...hreadid=572699


Franz Verga

Insert formula into a cell doesn't work :S
 
"s80NL" ha scritto nel
messaggio ...

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



Tom Ogilvy

Insert formula into a cell doesn't work :S
 
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.

--
Regards,
Tom Ogilvy


"s80NL" wrote:


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


--
s80NL


------------------------------------------------------------------------
s80NL's Profile: http://www.excelforum.com/member.php...o&userid=36374
View this thread: http://www.excelforum.com/showthread...hreadid=572699




All times are GMT +1. The time now is 10:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com