0

Question
I want a drop down list, where each item would have a separate value and when one item is selected, the corresponding value shall be posted in a separate cell.

For example, say the items to appear on the list are A, B, C, D and the corresponding values are, 10, 20, 30, 40. Say, when the user selects B, the corresponding value 20 is posted in another cell.

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by AEA
0

hi, please check attached file. see if this is what you're trying to do.
below is the code. Hope it helps :()

Private Sub ComboBox1_Change()

Select Case ComboBox1.Value

   Case "A"
   
       Cells(1, 2).Value = "10"
   
   Case "B"
   
     Cells(1, 2).Value = "20"
    
   Case "C"
   
     Cells(1, 2).Value = "30"
    
   Case "D"
   
     Cells(1, 2).Value = "40"

End Select

End Sub


Private Sub Workbook_Open()

With Sheet1.ComboBox1

  .AddItem "A"
  .AddItem "B"
  .AdItem "C"
  .AddItem "D"

End With

End Sub

Edited by cguan_77: n/a

0

how about a nested if statement: if (cell1="a",1, if(cell1="b", 2, if...
or a vlookup table

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.