instr problem with formula

S

Shell

I am trying to use the following

If InStr(1, "C:\", Range(strC & r).Formula) > 0 Then
Print #1, r & strC & " " & " " & Range(strC & r).Formula
End If

strC = D
r = 21
Range(strC & r).Formula = "=(ISERROR(GET
PIVOTDATA("EQPSERIAL",'C:\Reports..........."

The print statement never happens.

Can anyone tell me what is wrong?

Thanks
 
D

Dave Peterson

There's another argument you can specify to make sure you don't have to worry
about upper/lower case.

vbTextCompare

Check VBA's help for instr and you'll see more info.

Maybe it's c:\ in the formula???

Or maybe you're looking at the wrong cell?
 
R

Rick Rothstein

Your syntax on the InStr function is incomplete... as constructed, your
statement is looking for this...

"C:\", Range(strC & r).Formula

inside the string value of 1 (VB converts your number to a string). Why,
because you only specified two arguments to the InStr function. The first
argument is optional... it is the starting point for the search and defaults
to 1 when not specified. If you specify the starting position as a number,
then it must be followed by two string argument... the string to search
followed by the string being looked for. I can't give you a corrected
statement for you to look at because you didn't tell us what string you were
looking for inside of that path string.
 

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