Calculation in real time in userform

hhh

New Member
Joined
Mar 15, 2011
Messages
12
Hi All,


Any brother here can help to provide Calculation in real time in userform.



I have a user form which displayed:

Good Average Poor
3 2 1

Result(%): 3/(3+2+1)* 30%

Any body can help.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Code:
Any brother here can help to provide Calculation in real time in userform.
Code:
[FONT=Courier New]Good Average Poor[/FONT]
[FONT=Courier New]3 2 1[/FONT]
[FONT=Courier New]Result(%): 3/(3+2+1)* 30%[/FONT]
yea perhaps sis:biggrin:


is your values Good Average Poor in different textboxes?
and when you click on button wants the results in another text box showing you the realtime result below evertime you hit the button?
Result(%): 3/(3+2+1)* 30%



try something like this...
this code can be shorter but for understanding purpose... =)
Code:
[/FONT][/FONT][FONT=Courier New][FONT=Courier New]Option Explicit[/FONT][/FONT]
[FONT=Courier New][FONT=Courier New]Private Sub CommandButton1_Click()[/FONT]
[FONT=Courier New]'3/(3+2+1)* 30%[/FONT]
[FONT=Courier New]Dim x ' Good[/FONT]
[FONT=Courier New]Dim y 'Averagne[/FONT]
[FONT=Courier New]Dim z 'Poor[/FONT]
[FONT=Courier New]Dim rel ' result[/FONT][/FONT]
[FONT=Courier New][FONT=Courier New]x = Me.Good.Value[/FONT]
[FONT=Courier New]y = Me.Ave.Value[/FONT]
[FONT=Courier New]z = Me.Poor.Value[/FONT][/FONT]
[FONT=Courier New][FONT=Courier New]rel = x / (x + y + z) * 30[/FONT]
[FONT=Courier New]Me.result.Value = Format(rel, "0.0%")[/FONT]
[FONT=Courier New]End Sub[/FONT]
[/FONT]

[FONT=Courier New][FONT=Courier New]





I am not quite sure what u want...
 
Last edited:
Upvote 0
Put four text boxes onto UserForm1, name it as txtGood, txtAverage, txtPoor, txtResult.
Then try the code shown below.

Code of Module1
Rich (BB code):

' Code of Module 1
Sub FormShow()
  UserForm1.Show
End Sub

Code of UserForm1
Rich (BB code):

' Code of UserForm1
' Textboxes of the form are: txtGood, txtAverage, txtPoor, txtResult

Private Sub UserForm_Initialize()
  txtGood = 3
  txtAverage = 2
  txtPoor = 1
  MyCalc
End Sub

Sub MyCalc()
  txtResult = Format(0.3 * Val(txtGood) / (Val(txtGood) + Val(txtAverage) + Val(txtPoor)), "0.0%")
End Sub

Private Sub txtAverage_Change()
  MyCalc
End Sub

Private Sub txtGood_Change()
  MyCalc
End Sub

Private Sub txtPoor_Change()
  MyCalc
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,908
Members
452,949
Latest member
beartooth91

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