PC Review


Reply
Thread Tools Rate Thread

Create List for ComboBoxes

 
 
Benjamin
Guest
Posts: n/a
 
      19th Oct 2009
I need to create a dropdown combobox that has the names from Columb B in
Sheet "Names"

The combobox is in Form FrmMTCLog
the drop down is: combobox1
I need the combobox1 to have a list of all the names from Sheet"Names" Cell
b2 and down to the last filled in Column.


 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      19th Oct 2009
One way:

In the _initialize procedure:

with worksheets("Names")
me.combobox1.list = .range("B2",.cells(.rows.count,"B").end(xlup)).value
end with

(last filled in column B, right???)



Benjamin wrote:
>
> I need to create a dropdown combobox that has the names from Columb B in
> Sheet "Names"
>
> The combobox is in Form FrmMTCLog
> the drop down is: combobox1
> I need the combobox1 to have a list of all the names from Sheet"Names" Cell
> b2 and down to the last filled in Column.


--

Dave Peterson
 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      20th Oct 2009
Private Sub UserForm_Initialize()
rng = Sheets("Names").Cells(Rows.Count, 2).End(xlUp).Address
Me.FrmMTCLog.RowSource = "Names!$B$2:" & rng
End Sub




"Dave Peterson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> One way:
>
> In the _initialize procedure:
>
> with worksheets("Names")
> me.combobox1.list = .range("B2",.cells(.rows.count,"B").end(xlup)).value
> end with
>
> (last filled in column B, right???)
>
>
>
> Benjamin wrote:
>>
>> I need to create a dropdown combobox that has the names from Columb B in
>> Sheet "Names"
>>
>> The combobox is in Form FrmMTCLog
>> the drop down is: combobox1
>> I need the combobox1 to have a list of all the names from Sheet"Names"
>> Cell
>> b2 and down to the last filled in Column.

>
> --
>
> Dave Peterson



 
Reply With Quote
 
JBeaucaire
Guest
Posts: n/a
 
      20th Oct 2009
Easiest way is to do some work on the sheet first.

============
CREATE A DYNAMIC NAMED RANGE OF OPTIONS
1) Open the Named Range box (Insert > Name > Define)
2) In the "Names in Workbook" line, type in a name...for instance OPTIONS
3) At the bottom in the "Refers To" line, enter this dynamic formula:

=INDEX(Sheet2!$B:$B, 2):INDEX(Sheet2!$B:$B, COUNTIF(Sheet2!$B:$B,">"""))

4) Click ADD, then Close

You now have a named range called "Options" the keeps itself expanded to
include all the items in Sheet2, range B2>bottom of that data range. You
won't ever have to edit it.

============
CONNECT YOUR COMBOBOX TO THE NAMED RANGE
1) Right-Click on your combobox and select PROPERTIES
2) In the LISTFILLRANGE enter the value of OPTIONS


Your combobox is now linked permanently to the dynamic range "Options".

Does that help?

--
"Actually, I *am* a rocket scientist." -- JB
(www.MadRocketScientist.com)

Your feedback is appreciated, click YES if this post helped you.


"Benjamin" wrote:

> I need to create a dropdown combobox that has the names from Columb B in
> Sheet "Names"
>
> The combobox is in Form FrmMTCLog
> the drop down is: combobox1
> I need the combobox1 to have a list of all the names from Sheet"Names" Cell
> b2 and down to the last filled in Column.
>
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      20th Oct 2009
Using the .rowsource property is another way.

But I would use something like:

Private Sub UserForm_Initialize()
Dim rng as Range

with worksheets("Names")
set rng = .range("B2",.Cells(.Rows.Count, "B").End(xlUp))
end with

'I think the form was named FrmMTCLog.
me.combobox1.RowSource = rng.address(external:=true)

End Sub

Then if the worksheet name changed, I'd only have one spot to fix (or use the
Codename for that sheet and not have to worry???).





JLGWhiz wrote:
>
> Private Sub UserForm_Initialize()
> rng = Sheets("Names").Cells(Rows.Count, 2).End(xlUp).Address
> Me.FrmMTCLog.RowSource = "Names!$B$2:" & rng
> End Sub
>
> "Dave Peterson" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > One way:
> >
> > In the _initialize procedure:
> >
> > with worksheets("Names")
> > me.combobox1.list = .range("B2",.cells(.rows.count,"B").end(xlup)).value
> > end with
> >
> > (last filled in column B, right???)
> >
> >
> >
> > Benjamin wrote:
> >>
> >> I need to create a dropdown combobox that has the names from Columb B in
> >> Sheet "Names"
> >>
> >> The combobox is in Form FrmMTCLog
> >> the drop down is: combobox1
> >> I need the combobox1 to have a list of all the names from Sheet"Names"
> >> Cell
> >> b2 and down to the last filled in Column.

> >
> > --
> >
> > Dave Peterson


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
create dynamic comboboxes Martin Microsoft Excel Programming 2 3rd Jul 2009 05:05 PM
Unique list for multiple comboboxes. Juju Microsoft Access Forms 1 28th Feb 2008 08:34 AM
Re: Help needed - populating comboboxes from list?? Phillip Microsoft Excel Programming 0 19th Jan 2007 06:50 PM
Re: Help needed - populating comboboxes from list?? merjet Microsoft Excel Programming 0 19th Jan 2007 03:57 AM
How do I create custom collections that can be bound to comboboxes? Don Microsoft VB .NET 2 8th Nov 2004 03:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:25 AM.