Create a activecell from the listbox?

  • Thread starter Thread starter Oggy
  • Start date Start date
O

Oggy

Hi
Does anyone have a code for making my selection in a listbox on a form
my activecell in the worksheet.

Thanks in advance
 
Making several assumptions:

Private Sub Listbox1_Click()
Dim rng as Range
set rng = Range(me.Listbox1.RowSource)
rng.columns(1).Cells(me.Listbox1.ListIndex + 1).Select
End Sub
 
On the form you presumably have an ok or goto button (here CommandButton1)
and a the double_click event for the list box (here ListBox1).

Set up these three sub as try it would assuming you have a the two controls.

Private Sub CommandButton1_Click()
ActiveSheet.Range(ListBox1.Value).Select
Me.Hide
Unload Me
End Sub

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
CommandButton1_Click
End Sub

Private Sub UserForm_Initialize()
ListBox1.AddItem "A1"
ListBox1.AddItem "B2"
ListBox1.AddItem "C3"
End Sub
 
Activecell.value = Me.ListBox1.Value

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
 

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

Back
Top