How do I enter a spreadsheet formula into a userform?

  • Thread starter Thread starter yeekiat
  • Start date Start date
Y

yeekiat

Hi,

I would like to create a userform whereby the user can enter a
spreadsheet formula into a userform. The userform should also have a
done button so that when the done button is clicked, the formula is
stored in another cell in this worksheet.

Which control do I use to achieve this? The RefEdit doesn't work and
the Textbox doesn't seem right either.

Regards,
Yee Kiat
 
In the event that people might be confused with what I'm trying to do,
let me re-explain the problem.

Lets say I want to have a formula in cell C4 that contains the formula
=SUM(C1:C3)

I want to be able to create a userform that allows the user to enter
the formula =SUM(C1:C3) in a textbox or something that else that does
the job. When a 'Done' button is pressed on the userform, the formula
is placed in the cell C4.

Hope someone can help me out on this.

YeeKiat
 
Here is the general idea:

Sub yeekiat()
Dim s As Variant
s = Application.InputBox(Prompt:="Enter Equation:", Type:=0)
Range("C4").Formula = s
End Sub
 

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

Back
Top