ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Create a activecell from the listbox? (https://www.excelbanter.com/excel-programming/380690-create-activecell-listbox.html)

Oggy

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

Thanks in advance


Tom Ogilvy

Create a activecell from the listbox?
 
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

--
Regards,
Tom Ogilvy

"Oggy" wrote in message
oups.com...
Hi
Does anyone have a code for making my selection in a listbox on a form
my activecell in the worksheet.

Thanks in advance




Martin Fishlock

Create a activecell from the listbox?
 
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


--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Oggy" wrote:

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

Thanks in advance



Bob Phillips

Create a activecell from the listbox?
 
Activecell.value = Me.ListBox1.Value

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Oggy" wrote in message
oups.com...
Hi
Does anyone have a code for making my selection in a listbox on a form
my activecell in the worksheet.

Thanks in advance





All times are GMT +1. The time now is 10:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com