View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tone[_4_] Tone[_4_] is offline
external usenet poster
 
Posts: 5
Default ByRef Argument Type mismatch

On 2 Jul, 14:10, "Bob Phillips" wrote:
Works fine for me. You may need to give us more code.

Or even don't use Formula as a variable name, better to use say mFormula.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Tone" wrote in message

...



I have some code that looks like:


Sub doToCells()
*Dim formula As String
*...
*formula = InputBox(message, title, defString)
*pr_doToCells formula
end sub


Private Sub pr_doToCells(formula As String)
* *If formula < "" Then
* * * *formula = Replace(formula, ..., ...)
* * * *...
* *End If
End Sub


But I get an error - ByRef Argument type mismatch when it compiles -
complaining about the "formula" used as an argument to pr_doToCells.
Cannot understand why, and the problem disappears if I put parentheses
around the "formula" argument when I call it.


Any ideas?


Thanks
Tone- Hide quoted text -


- Show quoted text -


I assign to "formula" in the second procedure & I think that's what's
upsetting the compiler. Adding a "ByVal" to the argument declaration
in pr_doToCells solves the problem. I guess I just don't fully
understand parameter passing in VB.

Thanks for trying this out and helping me isolate the issue.

Cheers

Tone