LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default ListBox

"Seth" wrote in message
...
I have a listbox control with columnheaders. How can I,
at run time, get the values of these headers (if
possible)?


Hi Seth,

The easiest way to do this is to read the RowSource property of the
ListBox, convert it into a Range object, then get the row directly above it,
which contains the headers. Here's an example of how this would work:

Private Sub CommandButton1_Click()
Dim rngCell As Range
Dim rngHeaders As Range
Set rngHeaders = Application.Range(ListBox1.RowSource) _
.Offset(-1, 0).Resize(1)
For Each rngCell In rngHeaders
MsgBox rngCell.Value
Next rngCell
End Sub

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *



 
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
Listbox 2 takes the value of Listbox 1 Illya Teideman Excel Discussion (Misc queries) 3 April 10th 07 03:20 PM
listbox B conditional of input in Listbox A Kim K Excel Discussion (Misc queries) 1 October 31st 06 08:27 PM
Listbox B if LIstbox A equals Kim K Excel Discussion (Misc queries) 2 October 31st 06 07:03 PM
ListBox (maybe?) ... If so, how? Ken Excel Discussion (Misc queries) 3 December 15th 04 10:16 PM
Sorting ListBox results or transposing ListBox values to other cells for sorting Rob[_8_] Excel Programming 1 July 9th 03 04:35 AM


All times are GMT +1. The time now is 03:20 AM.

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"