Private Sub events

jose001

Board Regular
Joined
Mar 27, 2006
Messages
103
Hi everyone,

I have two textboxes and one combobox on a multipage page. I'm trying to get vba to autofill the third textbox when either the first textbox or the combox change but for obvious reasons below, I can only get it to update when I change the first textbox. Is it possible to have two events in the private sub or am I going about this the wrong way?


Code:
Private Sub TextBox1_Change()
Dim i As Integer
i = Val(TextBox1)


If ComboBox2.Value = "man" Then
TextBox2.Value = i * 50
ElseIf ComboBox2.Value = "woman" Then
TextBox2.Value = i * 60
ElseIf ComboBox2.Value = "boy" Then
TextBox2.Value = i * 70
ElseIf ComboBox2.Value = "girl" Then
TextBox2.Value = i * 80
ElseIf ComboBox2.Value = "dog" Then
TextBox2.Value = i * 90
ElseIf ComboBox2.Value = "cat" Then
TextBox2.Value = i * 100
ElseIf ComboBox2.Value = "Senior Director" Then
TextBox2.Value = i * 160
End If

End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi Andrew,

Thanks for your reply :) I know that procedure also but is it not possible to monitor both the textbox and combobox for changes at the same time rather than putting two separate subs? I'm not sure that makes sense to anyone reading this but there's already a lot of code so I'm trying to to add more to it :)
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,729
Members
452,939
Latest member
WCrawford

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