Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Retrieve item names in ListBox

Using Office xp, Win xp
I want to find out some details about the
controls on a worksheet, the number and
the items that head the ListBox and the
items in the list for checking purposes.

so far I have the following code:
Dim i as Integer, cntShapes as Integer
cntShapes = ActiveSheet.Shapes.Count
i = 1
Do Until i cntShapes
shpName = ActiveSheet.Shapes(i).Name
ActiveSheet.Range("F" & i) = i
ActiveSheet.Range("G" & i) = shpName
i = i + 1
Loop

This gives me a column of numbers 1 to 36
and an adjacent column of shpName values Control 1 to
Control 36

How can I retrieve using code the items in each
Control (list box) or maybe
only the first item at the top of each list box?
Any help appreciated!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Retrieve item names in ListBox

Item selected

Listbox1.Value

All items

With Activesheet.Listbox1
For i = 0 to .ListCount -1
msgbox .List(i)
Next
End With

--

HTH

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

"Peter Jamieson" wrote in message
...
Using Office xp, Win xp
I want to find out some details about the
controls on a worksheet, the number and
the items that head the ListBox and the
items in the list for checking purposes.

so far I have the following code:
Dim i as Integer, cntShapes as Integer
cntShapes = ActiveSheet.Shapes.Count
i = 1
Do Until i cntShapes
shpName = ActiveSheet.Shapes(i).Name
ActiveSheet.Range("F" & i) = i
ActiveSheet.Range("G" & i) = shpName
i = i + 1
Loop

This gives me a column of numbers 1 to 36
and an adjacent column of shpName values Control 1 to
Control 36

How can I retrieve using code the items in each
Control (list box) or maybe
only the first item at the top of each list box?
Any help appreciated!




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Retrieve item names in ListBox

G'day Bob,
Thank you for your input!

When I ran the code:
With Activesheet.Listbox1
For i = 0 to .ListCount -1
msgbox .List(i)
Next
End With

I got the message:

Run-time error '438'
Object doesn't support this property or method

The error referred to: Activesheet.Listbox1

Any clues as to what the problem may be?
Cheers


"Bob Phillips" wrote in message
...
Item selected

Listbox1.Value

All items

With Activesheet.Listbox1
For i = 0 to .ListCount -1
msgbox .List(i)
Next
End With

--

HTH

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

"Peter Jamieson" wrote in message
...
Using Office xp, Win xp
I want to find out some details about the
controls on a worksheet, the number and
the items that head the ListBox and the
items in the list for checking purposes.

so far I have the following code:
Dim i as Integer, cntShapes as Integer
cntShapes = ActiveSheet.Shapes.Count
i = 1
Do Until i cntShapes
shpName = ActiveSheet.Shapes(i).Name
ActiveSheet.Range("F" & i) = i
ActiveSheet.Range("G" & i) = shpName
i = i + 1
Loop

This gives me a column of numbers 1 to 36
and an adjacent column of shpName values Control 1 to
Control 36

How can I retrieve using code the items in each
Control (list box) or maybe
only the first item at the top of each list box?
Any help appreciated!






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Retrieve item names in ListBox

Peter,

Is it a Forms control?

Try this if so

Dim i As Long

With ActiveSheet.ListBoxes("List Box 1")
For i = 1 To .ListCount
MsgBox .List(i)
Next
End With


--

HTH

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

"Peter Jamieson" wrote in message
...
G'day Bob,
Thank you for your input!

When I ran the code:
With Activesheet.Listbox1
For i = 0 to .ListCount -1
msgbox .List(i)
Next
End With

I got the message:

Run-time error '438'
Object doesn't support this property or method

The error referred to: Activesheet.Listbox1

Any clues as to what the problem may be?
Cheers


"Bob Phillips" wrote in message
...
Item selected

Listbox1.Value

All items

With Activesheet.Listbox1
For i = 0 to .ListCount -1
msgbox .List(i)
Next
End With

--

HTH

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

"Peter Jamieson" wrote in message
...
Using Office xp, Win xp
I want to find out some details about the
controls on a worksheet, the number and
the items that head the ListBox and the
items in the list for checking purposes.

so far I have the following code:
Dim i as Integer, cntShapes as Integer
cntShapes = ActiveSheet.Shapes.Count
i = 1
Do Until i cntShapes
shpName = ActiveSheet.Shapes(i).Name
ActiveSheet.Range("F" & i) = i
ActiveSheet.Range("G" & i) = shpName
i = i + 1
Loop

This gives me a column of numbers 1 to 36
and an adjacent column of shpName values Control 1 to
Control 36

How can I retrieve using code the items in each
Control (list box) or maybe
only the first item at the top of each list box?
Any help appreciated!








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
retrieve data item in terminal cell bluegospel Excel Discussion (Misc queries) 2 June 7th 09 07:32 PM
Last Item of Listbox not getting displayed Raj Excel Discussion (Misc queries) 0 April 22nd 08 10:58 AM
Adding item in listbox volabos Excel Worksheet Functions 0 December 3rd 07 11:47 AM
Adding item in listbox volabos Excel Worksheet Functions 0 December 3rd 07 11:27 AM
Item order in ListBox [email protected] Excel Discussion (Misc queries) 1 June 16th 06 01:15 PM


All times are GMT +1. The time now is 08:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"