Dmcritchie.mvps.org



[pic]

| |

Sub UserForm_Activate()

Dim WS As Excel.Worksheet

ActiveSheet.Shapes("List Box 5").Select

With Selection

.ListFillRange = "C1:C12"

.LinkedCell = ""

.MultiSelect = xlNone

.Display3DShading = False

' .Clear

For Each WS In ActiveWorkbook.Worksheets

.AddItem WS.Name

Next WS

End With

End Sub

Sub listbox5_change()

End Sub

There are two listboxes. One from the forms toolbar (xl5 - xl2000) and one

from the Controls Toolbox Toolbar (xl97 - xl2000)

To refer to the latter

for each cell in Range("A1:A10")

worksheets("Sheet1").Listbox1.Additem cell.Value

Next

for a listbox on a worksheet it is probably easier to use the ListFillRange

property and assign it to a range

sheet1!A1:A10

If you want to change the name, right-click on it in design mode and select

properties. Change the first property: Name

For code, right-click on the sheet tab and select view code. In the left

dropdown f the module select the name of the listbox. In the right dropdown

select Click. Add the line in the center:

Private Sub Listbox1_click()

ActiveCell.Value = Listbox1.value

End sub

Regards,

Tom Ogilvy

MVP Excel

Dave Martin wrote in message

news:8p01mr$brr$1@slb6.atl....

> Can someone give me the syntax to get the text from a specific entry on a

> listbox?

--Answer:

sStr = Userform1.Listbox1.List(2)

2 is the third item since the list is zero based in an activeX control  - if

from the forms toolbar, use 3.

if it is a multicolumn list activeX control:

sStr = Userform1.Listbox1.List(2,0)  for the first column, 3rd row.

Regards,

Tom Ogilvy

MVP Excel

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download