Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mathematical Formulae in VBA 1

Status
Not open for further replies.

VC2002

Technical User
Nov 15, 2002
34
IE
Hi!

I want to use a Control Button to run a simple formula in Microsoft Excel.

The problem is that VBA won't recognise the text portion of the formula. I'm sure there's a simple answer, but I can't figure it out! The code is as follows:

Private Sub cmdCheck_Click()

Range("K118", Cells(R, 11)).Formula = _
"=IF(K118 = 1,"YES",0)"

End Sub

I realise that the quotations around the text YES is the problem, but how do you solve it?

Thanks in advance!
 
what about using

if k118 = 1 then parameter = true else = false
 
From what you've posted, I don't think that this is the most efficient way of doing this (the answer by the way is more """""""") - you would be better doing the calc in VBA and depositing the answer into the cell Rgds
~Geoff~
 
Thanks for replying so quickly!

I know that I could use Loops and If statements to do that one particular function, but there are some more complex ones that require me to return a number of different strings and it would just be easier to copy the formulae from Excel and paste them into the VBA module.

Geoff, when you say 'more """"""', what exactly do you mean? I would be really grateful if you could explain!







 
Add an extra " for each literal quotation mark, i.e.


range("K118", Cells(R, 11)).Formula = "=IF(K118 = 1,""YES"",0)"

Rob
[flowerface]
 
Thanks again for all your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top