View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
keiji kounoike keiji kounoike is offline
external usenet poster
 
Posts: 199
Default How to program this?


If you have dropdown A ,B and textBox C in Userform, try something like
this. This code should be written in Userform module.
ComboBox1 means dropdown A, ComboBox2 means dropdown B and textBox C
means TextBox1.

Private Sub ComboBox1_Change()
If ComboBox1.Value < ComboBox2.Value Then
Me.TextBox1.Text = "Discrepancy"
Else
Me.TextBox1.Text = ""
End If
End Sub

Private Sub ComboBox2_Change()
If ComboBox1.Value < ComboBox2.Value Then
Me.TextBox1.Text = "Discrepancy"
Else
Me.TextBox1.Text = ""
End If
End Sub

Keiji

sam wrote:
I am new to excel programming and am not able to get it to work.
Can someone help me with this?
How can I Compare the text values in cell A and B and populate cell C
accordingly?

A is a dropdown with following values
compile, edit, audit

B is a dropdown and has the same values as A
compile, edit, audit

C is a text box that auto populates with 'Descripency' depending on what is
selected for A and B.

What I am thinking should be done is:
Compare the text strings in A and B using StrComp() function,
It will return a value -1,0,1
Then write an If statement to populate the value in C.

But, How does excel compare the text values in A and B?
For eg, I want Discrepancy to be populated in C if audit is selected in B
and edit is selected in A. How will excel know this? I cannot manualy write
down what text value preeceds what as there are a LOT of values.

I hope I made it clear.

Thanks in Advance