error msg in function .... any ideas????

  • Thread starter Thread starter Kelvin
  • Start date Start date
K

Kelvin

Sub RIRthreedates()
Range("m3").Formula = "=IF(count(i3:k3)<3,"",if(i3>j3,i3,if(j3>k3,
j3,k3)))" End Sub

This subR causes a runtime error " application defined or object defined
error" 1004
If I put the formula in the cell directly , it works fine.

if I use the equation Range("m2").Formula = "=counta(a3:a5)" in the
subR
it works fine.

why would the above line cause this error. Can someone shed some light????

thanks
 
You have to double up the double quotes in the string:

Sub RIRthreedates()
Range("m3").Formula _
= "=IF(count(i3:k3)<3,"""",if(i3>j3,i3,if(j3>k3,j3,k3)))"
End Sub
 
Dave,

Thanks for the tip. The doubling up on the quotes worked.

Could you enlighten me as to why the four quotes are neccessary?

Thanks to all for your input.
 
In Visual Basic text begins and ends with quotes. To express "", you must
put quotes around it. Thus """".

Tyro

Kelvin said:
Dave,

Thanks for the tip. The doubling up on the quotes worked.

Could you enlighten me as to why the four quotes are neccessary?

Thanks to all for your input.
 
JP,
Actually what I was looking for, and what actually happens is that the ""
gives me a blank cell if the condition is not met.

I wasn't sure why I would need the quotes around my quotes for this?

--
KWB


JP said:
When you actually want quotes to appear, you have to, put them in
quotes. :-)


HTH,
JP
 
Back
Top