PDA

View Full Version : Formula Editor/Bar in UserForm TextBox?



xtinct2
05-19-2017, 11:28 PM
Hi,

I have a Userform w/ text boxes who's inputted value populates a certain cell (currently only supports static values).
Is it possible to have a userform textbox mimic a formula editor/bar so that the imputted values can be formulas that you can either type or click the relevant cells to write?

Example of the formula editor/bar I'm thinking of -- (basically can i add this to a user form)?:

1913

This way, end users can write a formula and that formula will be the text box's value, which will then populate the predetermined cell -- still as a formula (i.e. the value in the cell that the texbox populates is not static, but a dynamic formula)

This would help a ton, if possible!
Let me know if unclear

Thank you!

Logit
05-20-2017, 07:24 AM
.
.
Paste this code in your UserForm for the CommandButton.



Option Explicit

Private Sub CommandButton1_Click()
Sheets("Sheet1").Range("A3").Formula = TextBox1.Text
End Sub


This example presumes two numbers, one in A1 and one in A2 ..... with the total in A3.

ex: =SUM(A1:A2)

or

ex: =A1-A2

or

ex: =A1*A2

xtinct2
05-23-2017, 12:13 AM
.
.
Paste this code in your UserForm for the CommandButton.



Option Explicit

Private Sub CommandButton1_Click()
Sheets("Sheet1").Range("A3").Formula = TextBox1.Text
End Sub


This example presumes two numbers, one in A1 and one in A2 ..... with the total in A3.

ex: =SUM(A1:A2)

or

ex: =A1-A2

or

ex: =A1*A2

You'd have to type in the formula and cell references for this method. Is it possible to add a formula bar to the UserForm -- so that you can click a cell?

Logit
05-23-2017, 12:35 AM
I don't understand.