I need major help fast!!!!!

M

Mr. Jay

Hello Everyone,

I am new to this post. I am stumped and figured I would ask the
gurus.

I am using VBA Excel to create a UserForm that will allow the user to
select a value from ComboBox1 and another Value from Combobox2 and
based on the two selections Textbox3 is populated with a message that I
define.

For Example: If the user choose China from Combox1 and USA from
Combobox2 Then the result display in Textbox3 would be "you will pay
taxes here after 184 days"

The problem is in column A and B of the spreadsheet I have 146
countries ( the fill for combo boxes 1&2), so to use an If..Than...Else
statement would be extremely labor intensive.

Could anyone help?:confused:
 
M

Mr. Jay

Could you give please give me a little more detail as to how this might
work using VBA. I could set up my spreadsheet like you described.
 
D

Dave Peterson

Option Explicit

Private Sub CommandButton1_Click()
Dim myRow As Variant
Dim myCol As Variant
Dim myRng As Range
Dim myVal As Variant

Set myRng = Worksheets("sheet99").Range("a1:x33") 'whatever you use here

myRow = Application.Match(ComboBox1.Value, myRng.Columns(1), 0)
myCol = Application.Match(ComboBox2.Value, myRng.Rows(1), 0)

If IsNumeric(myRow) _
And IsNumeric(myCol) Then
myVal = myRng.Cells(myRow, myCol).Value
Else
myVal = "Missing"
End If

MsgBox myVal
End Sub
 
Top