VBA Formula Result Different Than Manual Formula Result

O

ob3ron02

Hi I've got a macro designed to fill cells with formulas when executed
The results are sometimes incorrect but when writing the exact sam
formula manually, the results are correct.

For example one of the formulas that I'm using is


Code
-------------------
Dim ReportD As String
ReportD = "=IF(ISNA(MATCH(R[0]C[-2],PID!B:B,0))=FALSE, ""x"","""")"
Worksheets("Report").Range("D5").Offset(counter, 0).Formula = Report
-------------------


When this is executed the formula in D5 becomes
Code
-------------------
=IF(ISNA(MATCH(B5,PID!B:B,0))=FALSE, "x",""
-------------------
which returns an "x". Now if I type in the formul
Code
-------------------
=IF(ISNA(MATCH(B5,PID!B:B,0))=FALSE, "x",""
-------------------
in an adjacent cell, it returns the correct result, which is blank.

What might be causing this?

BTW, the Version of Excel I'm using is 2000 w/ SP
 
D

Don Guillett

Your method is used when
range("a1")= "=yourformula"
when you just do in vba you need to site the range and forget the "= "
myvar=match(range("etc
 

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