Select 1st ListBox, return data from 2nd

D

Dave

Userform1 contains listbox1 and listbox2
Listbox1 contains the values: 1 2 3 4 5 in A1:A5
Listbox2 contains the values: a b c d e in B1:B5

Userform1 is called from a macro, the macro prompts a
user to select one of the options in listbox1. But
opposed to returning the value 1-5, I need it to return
the value from the adjacent cell. So if the user enters
3, it returns c.
The user needs to key in 3, not a mouse click.

Private Sub ListBox1_Click()
ActiveCell.Value = ListBox1
Unload Me

End Sub

I know I have seen this here before, but cannot find it.

Thanks,

Dave
 
B

Bob Phillips

Hi Dave,

Is this what you want

Private Sub ListBox1_Click()
ActiveCell.Value = ListBox2.List(Listbox1.ListIndex)
Unload Me

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
D

Dave

Bob,

YES! Works Great.

As great as the view you are fortunate to look across...
You are very fortunate.

Thank you.

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top