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

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
 
D

Dave Peterson

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
 
K

Kelvin

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.
 
T

Tyro

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.
 
K

Kelvin

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
 

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