List Box catalyst to cell reference

  • Thread starter Thread starter Markus
  • Start date Start date
M

Markus

I would like that when an option is chosen in a list box
it changes the reference for certain cells. If the first
option is chosen then cell a4 = another workbook sheet1
cell g18 If the second option is chosen then cell a4 =
another workbook sheet2 cell b15. I tried to use the IF
formula but i guess i do may not properly understand how
to put the object into the formula. If this can be done in
VB i would apreciate that as well. Thanks for any help.

Markus
 
You could use the ListIndex property, which is zero-based so the first item
in the list is the 0th item in VBA:

Select Case ListBox1.ListIndex
Case 0 'First item in list
Range("A4").Value = Workbooks("OtherBook"). _
Worksheets("Sheet1").Range("G18").Value
Case 1 'Second item in list
Range("A4").Value = Workbooks("OtherBook"). _
Worksheets("Sheet2").Range("B15").Value
'etc
End Select

rename ListBox1 to whatever the name of your listbox is.

For more information for listboxes see www.rubbershoe.com/listbox.htm

Hth,
Tim Zych
 
Back
Top