Textboxes

Grobler

New Member
Joined
Aug 11, 2020
Messages
5
Office Version
  1. 2019
Platform
  1. Windows
Good Day,

Please assist,

I have multipole textboxes using multiple userforms.

I want to be able to enter a calculation i.e. =251+25+35+85 in a textbox on a userform and when I press the enter data command button I need to see the answer of that calculation i entered?

Please assist?

THank you
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
To sum numbers that are all in a single TextBox will require a convoluted approach and answer.
You can save yourself a ton of problems by placing each number into a separate textbox.
 
Upvote 0
the text boxes on the userforms represent different aspects of the data. the sum i mentioned above is for 1 thing unles i just use a calculator to add it up and enter the result in that text box
 
Upvote 0
You can calculate a properly-formed expression in a TextBox using the Evaluate function. So, if your TextBox is named TextBox1, then you can calculate the expression in it like this...

MsgBox Evaluate(TextBox1.Text)

Here I used a MessageBox to display the calculated result, but you can assign it to a variable, TextBox or whatever instead.
 
Upvote 0
if there is a calculation in the cell eg. +25+25 what code can i use to calculate the equation when i press enter data button?
 
Upvote 0
Assuming your Text Box is named TextBox1, maybe this in the button's Click event...

TextBox1.Value = Evaluate(TextBox1.Text)
 
Upvote 0
thank you Rick you have saved my life it is working beautifully

awesome
 
Upvote 0
@ Rick Rothstein,

Rick Please help me, i have done your code in my text box scenarios and it works, however i have 29 text boxes in in one user form so here is my question,
sometimes the data I enter on the userform only requires me to enter data in maybe 10 of the 29 textboxes, what code can i use to ignore the blank text boxes and still evaluate the ones with data?

Any Ideas please, Thank you.

Here is my code i am using for the one user form

Private Sub CommandButton4_Click()

Sheets("Stock Capture").Select
Range("a3").Select
TextBox1.Value = Evaluate(TextBox1.Text)
TextBox2.Value = Evaluate(TextBox2.Text)
TextBox3.Value = Evaluate(TextBox3.Text)
TextBox4.Value = Evaluate(TextBox4.Text)
TextBox5.Value = Evaluate(TextBox5.Text)
TextBox6.Value = Evaluate(TextBox6.Text)
TextBox7.Value = Evaluate(TextBox7.Text)
TextBox8.Value = Evaluate(TextBox8.Text)
TextBox9.Value = Evaluate(TextBox9.Text)
TextBox10.Value = Evaluate(TextBox10.Text)
TextBox11.Value = Evaluate(TextBox11.Text)
TextBox12.Value = Evaluate(TextBox12.Text)
TextBox13.Value = Evaluate(TextBox13.Text)
TextBox14.Value = Evaluate(TextBox14.Text)
TextBox15.Value = Evaluate(TextBox15.Text)
TextBox16.Value = Evaluate(TextBox16.Text)
TextBox17.Value = Evaluate(TextBox17.Text)
TextBox18.Value = Evaluate(TextBox18.Text)
TextBox19.Value = Evaluate(TextBox19.Text)
TextBox20.Value = Evaluate(TextBox20.Text)
TextBox21.Value = Evaluate(TextBox21.Text)
TextBox22.Value = Evaluate(TextBox22.Text)
TextBox23.Value = Evaluate(TextBox23.Text)
TextBox24.Value = Evaluate(TextBox24.Text)
TextBox25.Value = Evaluate(TextBox25.Text)
TextBox26.Value = Evaluate(TextBox26.Text)
TextBox27.Value = Evaluate(TextBox27.Text)
TextBox28.Value = Evaluate(TextBox28.Text)
TextBox29.Value = Evaluate(TextBox29.Text)
Unload Me
UserForm1.Hide
Sheet1.Select
dashboard.Show
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,038
Messages
6,122,798
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top