Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default populating a listbox

The listbox I have is populated by items on a worksheet. The items cannot be
moved in the worksheet because they are being used in a data validation. I
have code that links the listbox to the worksheet so when the item is
selected in the listox it is also selected on the worksheet. I need to be
able to reference only some of the list on the worksheet for the listbox.
e.g. I need say A6:A10 and A12:A15.
Any ideas?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default populating a listbox

You have a named range and change the named range before you call the user
form or you adjust the linked source and refresh the form.
--
Hope this helps
Martin Fishlock


"enyaw" wrote:

The listbox I have is populated by items on a worksheet. The items cannot be
moved in the worksheet because they are being used in a data validation. I
have code that links the listbox to the worksheet so when the item is
selected in the listox it is also selected on the worksheet. I need to be
able to reference only some of the list on the worksheet for the listbox.
e.g. I need say A6:A10 and A12:A15.
Any ideas?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default populating a listbox

Can you show me an example of this please?

Private Sub ListBox1_Click()
'This is the code for the listbox
'It links the listbox to the sheet
With activeworksheet
range("B63:B271")(UserForm1.ListBox1.ListIndex + 1).Select
End With
End Sub

This is my current code. I need my row source to include six columns.
B63:G271.
Not all the items in this range are needed.

"Martin Fishlock" wrote:

You have a named range and change the named range before you call the user
form or you adjust the linked source and refresh the form.
--
Hope this helps
Martin Fishlock


"enyaw" wrote:

The listbox I have is populated by items on a worksheet. The items cannot be
moved in the worksheet because they are being used in a data validation. I
have code that links the listbox to the worksheet so when the item is
selected in the listox it is also selected on the worksheet. I need to be
able to reference only some of the list on the worksheet for the listbox.
e.g. I need say A6:A10 and A12:A15.
Any ideas?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default populating a listbox

This is the code that gets the items in. I now realise that you cannot have
multiple ranges and so therefore will either have to make another list for
the data or manually add it to the list.

Private Sub UserForm_Initialize()

ListBox1.ColumnCount = 2
ListBox1.RowSource = "Name"

ListBox1.ControlSource = "e1"
'Place the ListIndex into cell a6
ListBox1.BoundColumn = 0

End Sub

--
Hope this helps
Martin Fishlock


"enyaw" wrote:

Can you show me an example of this please?

Private Sub ListBox1_Click()
'This is the code for the listbox
'It links the listbox to the sheet
With activeworksheet
range("B63:B271")(UserForm1.ListBox1.ListIndex + 1).Select
End With
End Sub

This is my current code. I need my row source to include six columns.
B63:G271.
Not all the items in this range are needed.

"Martin Fishlock" wrote:

You have a named range and change the named range before you call the user
form or you adjust the linked source and refresh the form.
--
Hope this helps
Martin Fishlock


"enyaw" wrote:

The listbox I have is populated by items on a worksheet. The items cannot be
moved in the worksheet because they are being used in a data validation. I
have code that links the listbox to the worksheet so when the item is
selected in the listox it is also selected on the worksheet. I need to be
able to reference only some of the list on the worksheet for the listbox.
e.g. I need say A6:A10 and A12:A15.
Any ideas?

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
Populating listbox Mick[_2_] Excel Discussion (Misc queries) 1 May 14th 08 10:48 PM
Populating listbox Andy Brown Excel Programming 3 August 16th 04 05:40 PM
Populating a ListBox ToddG Excel Programming 1 June 24th 04 03:18 AM
Populating combobox/listbox Torstein S. Johnsen[_2_] Excel Programming 1 May 13th 04 09:26 AM
Populating a userform 3 col listbox Martin[_13_] Excel Programming 0 April 19th 04 09:49 PM


All times are GMT +1. The time now is 01:16 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"