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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel 2013: VBA Userform to calculate and then drop answer into worksheet

Status
Not open for further replies.

pendle666

Technical User
Jan 30, 2003
295
GB
Hello

My userform has three boxes:

TxtBoxSalary - £0.00
TxtBox600 - £0.00
TaxBoxPercent - 0.0%

I want the user to enter figures into these fields, for example:

TxtBoxSalary - £1633.75
TxtBox600 - £610.43
TxtBoxPercent - 5.5%

When the user presses the Calculate command button I want the macro to perform the following calculation

(TxtBoxSalary / 31 * 16) * TxtBoxPercent + TxtBox600

And for the answer to be dropped into cell O35 in the worksheet.

Can someone give me an idea of where to start please? It's been a very long time since I did anything with userforms...


thank you very much


thank you for helping

____________
Pendle
 
Hi,

UserForm, Textboxes, calculate button, OK to worksheet button: do you really want all that? Forum707 VBA code required.

Why not simply 3 columns on your sheet rather than 3 textboxes, and a formula?
 
Unfortunately yes. This is a form which has been provided to us by an outside body for pension calculations, so I can't change it.

thank you for helping

____________
Pendle
 
People here at TT are willing to help you, but you should choose the right Forum for your question, like Skip suggested.

Anyway, try something like this:

Code:
Option Explicit

Private Sub CommandButton1_Click()

Sheet1.Range("O35").Value = (Val(TxtBoxSalary.Text) / 31 * 16) * Val(TxtBoxPercent.Text) + Val(TxtBox600.Text)

End Sub

You get 5448.17193548387 in cell O35

You still need some more code to ensure the entries into the text boxes are valid.

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top