Userform Textbox : If A and B conditons meet then show C value on userform

Ronald45

New Member
Joined
Jul 7, 2022
Messages
8
Office Version
  1. 2013
Platform
  1. Windows
Hello,

Im wondering if someone can help me. I want to setup a userform in a way that i need 2 conditions to fullfilled to show a value in a textbox.

In other terms, if my car model is A and its power is B, i need the price C to show up automatically in the price textbox. And i prefer to fill the prices manually without having to get to worksheets.

I tried this code but i dont get my price showing up.

VBA Code:
Private Sub Formulaire_activate()
If cboCar.Value = "Toyota" And cboPower.Value = "120 hp" Then
txtPrice.ShowValue = "10.000 $"
End If
End Sub


I'll be thankful if u can help me
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
after Private Sub Formulaire_activate() add

VBA Code:
debug.print "carValue: " & cboCar.Value & "     PowerValue: " & cboPower.Value

and report/post what you see in the immediate window.
 
Upvote 0
Thanks for the answer.

I add the debug print but nothing has changed and the immediate window shows nothing.
 
Upvote 0
after Private Sub Formulaire_activate() add

VBA Code:
debug.print "carValue: " & cboCar.Value & "     PowerValue: " & cboPower.Value

and report/post what you see in the immediate window.

I added the code you gave me but nothing has changed and the immediate window shows nothing.
 
Upvote 0
Your reply makes no sense to me. At the very least, it should have shown
VBA Code:
carValue:      PowerValue:

and if it did, that is not "nothing". It would mean that your combo values are null or are empty strings. You can step through the code and mouse over the combo references or put a break point on End Sub line and do that when it halts. Or using the break point, when it stops there, type this in the immediate window and hit enter at the end of the line you typed:
?cboCar.Value
If nothing visible is returned, therein lies your problem. If you get a number instead of "Toyota" you have a different problem but I don't think that will be the case.
 
Upvote 0

I am glad I did not spend any time trying for a solution. Some other people are spending time already on it.
 
Upvote 0
Solution
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: If Car = A and Power = B then show Price C value in the textbox automatically
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
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