Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

excel list box value

Status
Not open for further replies.

jordanh

Technical User
Nov 11, 2002
47
GB
Hi all,

I'm trying to use the selected value of a list box in VBA but I can't seem to extract it. I thought you could use something similar to the access form control variables; so just sheet1.ListBox1 or sheet1.ListBox1.value but neither work.

Does anyone know a way to do this?

Thanks in advance for any help,

Jordan
 
How are you trying to use it as it looks like you basically know what you're doing (that sounds a bit rude but it's not intended that way!)

The following line takes the value of a listbox, drawn on a sheets with a linked cell and a named range to fill values, then multiplies it by 2 and puts it in cell A2 on the same sheet

Code:
Private Sub ListBox1_Click()
Sheets(1).Cells(2, 1).Value = ListBox1.Value * 2
End Sub

Hope this helps

;-) If a man says something and there are no women there to hear him, is he still wrong? [ponder]
 
How are you trying to use it?

The following line takes the value of a listbox, drawn on a sheets with a linked cell and a named range to fill values, then multiplies it by 2 and puts it in cell A2 on the same sheet

Code:
Private Sub ListBox1_Click()
Sheets(1).Cells(2, 1).Value = ListBox1.Value * 2
End Sub

Hope this helps

;-) If a man says something and there are no women there to hear him, is he still wrong? [ponder]
 
Be very specific about what type of listbox you are working with: from the forms toolbar, from the control toolbox, or on a userform? They all work (and are accessed) just a little differently.
Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top