Using user input to generate a formula in a macro


Posted by Dominic on March 09, 2001 6:47 AM

I have created a macro that tests various formulas based on given data from a sheet. I now want an optional field in the user form that allows a user to enter a formula (using defined variable names) to test against the data and the other formulas.
At present when I create this I cannot get my code to recognise the input as a formula and actually run it



Posted by David Hawley on March 09, 2001 1:25 PM

Hi Dominic

If I understand you correctly you will probably need to tranfer the formula to a Worksheet cell to get the result. You can do this via a button, or whatever:


Private Sub CommandButton1_Click()
Dim MyFormula As String
MyFormula = TextBox1
Sheet1.Range("A1") = MyFormula
TextBox1 = Sheet1.Range("A1")
End Sub

Dave


OzGrid Business Applications