close

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 quot;you will pay
taxes here after 184 daysquot;

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

Could anyone help?--
Mr. Jay
------------------------------------------------------------------------
Mr. Jay's Profile: www.excelforum.com/member.php...oamp;userid=32350
View this thread: www.excelforum.com/showthread...hreadid=521070Maybe you can build a table.

Put the combobox1 values down column A and the combobox2 values across row 1.

Then you can use =index(match()) to retrieve the value.

You may want to read Debra Dalgleish's notes:
www.contextures.com/xlFunctions03.html

Look at examples 2 amp; 3.

quot;Mr. Jayquot; wrote:
gt;
gt; Hello Everyone,
gt;
gt; I am new to this post. I am stumped and figured I would ask the
gt; gurus.
gt;
gt; I am using VBA Excel to create a UserForm that will allow the user to
gt; select a value from ComboBox1 and another Value from Combobox2 and
gt; based on the two selections Textbox3 is populated with a message that I
gt; define.
gt;
gt; For Example: If the user choose China from Combox1 and USA from
gt; Combobox2 Then the result display in Textbox3 would be quot;you will pay
gt; taxes here after 184 daysquot;
gt;
gt; The problem is in column A and B of the spreadsheet I have 146
gt; countries ( the fill for combo boxes 1amp;2), so to use an If..Than...Else
gt; statement would be extremely labor intensive.
gt;
gt; Could anyone help?
gt;
gt; --
gt; Mr. Jay
gt; ------------------------------------------------------------------------
gt; Mr. Jay's Profile: www.excelforum.com/member.php...oamp;userid=32350
gt; View this thread: www.excelforum.com/showthread...hreadid=521070

--

Dave Peterson


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.--
Mr. Jay
------------------------------------------------------------------------
Mr. Jay's Profile: www.excelforum.com/member.php...oamp;userid=32350
View this thread: www.excelforum.com/showthread...hreadid=521070Option Explicit

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

Set myRng = Worksheets(quot;sheet99quot;).Range(quot;a1:x33quot;) '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 = quot;Missingquot;
End If

MsgBox myVal
End Sub
quot;Mr. Jayquot; wrote:
gt;
gt; Could you give please give me a little more detail as to how this might
gt; work using VBA. I could set up my spreadsheet like you described.
gt;
gt; --
gt; Mr. Jay
gt; ------------------------------------------------------------------------
gt; Mr. Jay's Profile: www.excelforum.com/member.php...oamp;userid=32350
gt; View this thread: www.excelforum.com/showthread...hreadid=521070

--

Dave Peterson

arrow
arrow
    全站熱搜

    software 發表在 痞客邦 留言(0) 人氣()