PC Review


Reply
Thread Tools Rate Thread

Combo Boxes getting data from Work Sheet.

 
 
Brian
Guest
Posts: n/a
 
      5th Jan 2010
I have a User Form that has a combo Box on it. Is it possible for the Combo
Box to get it's Data from a Work Sheet in the same Work Book as the User Form
instead of doing in Code as follows:

With Me.Engineer_2
.AddItem "1"
.AddItem "2"
.AddItem "3"
.AddItem "4"
.AddItem "5"
.AddItem "6"
End With

The reason I ask is because I would like to be able to set it up as follows:
Combo Box 1 = Customer 1
Combo Box 2 = State
Combo Box 3 = Site ID

User Picks the Customer, then the State for that Customer, then the Site ID
for that Customer.

Each State (9-States) has about 450 Sites for each of the 4 Customers, so
writing it in Code would take forever. Plus I already have all the Data in a
Work Book, so all I have to do is add a Sheet for each customer and Copy &
Paste the Data.

I want to use the Comboxes as a process of elimanation to narrow it down.


 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      5th Jan 2010
The only advantage of using the List or AddItem methods is that you can add
and delete items from the ComboBox, whereas, if you use the RowSource or
ListFillRange methods to populate the ComboBox then you cannot add and
delete items from the ComboBox. When using RowSource and ListFill range,
the worksheet range has to be modified to change the ComboBox content. That
said, you can use the RowSource or ListFillRange, as applicable, to populate
the ComboBox from the same workbook.

In the initialize event for the form:

Me.ComboBox1.RowSource = "Sheet1!A2:A11"

The above code would load data from Range("A2:A11") of sheet 1 in the active
workbook into the ComboBox1.

To set up the three controls as you have described and use the RowSource
method, you would need to list your customers in a single colum, the states
in a single column and the site Id in a single column with empty cells
purged and each column sorted alpha/numerically for best performance of the
ComboBox.

If this does not answer the question, then provide more detail.

"Brian" <(E-Mail Removed)> wrote in message
newsC1DDD5A-97D6-4029-AC33-(E-Mail Removed)...
>I have a User Form that has a combo Box on it. Is it possible for the Combo
> Box to get it's Data from a Work Sheet in the same Work Book as the User
> Form
> instead of doing in Code as follows:
>
> With Me.Engineer_2
> .AddItem "1"
> .AddItem "2"
> .AddItem "3"
> .AddItem "4"
> .AddItem "5"
> .AddItem "6"
> End With
>
> The reason I ask is because I would like to be able to set it up as
> follows:
> Combo Box 1 = Customer 1
> Combo Box 2 = State
> Combo Box 3 = Site ID
>
> User Picks the Customer, then the State for that Customer, then the Site
> ID
> for that Customer.
>
> Each State (9-States) has about 450 Sites for each of the 4 Customers, so
> writing it in Code would take forever. Plus I already have all the Data in
> a
> Work Book, so all I have to do is add a Sheet for each customer and Copy &
> Paste the Data.
>
> I want to use the Comboxes as a process of elimanation to narrow it down.
>
>



 
Reply With Quote
 
Leung
Guest
Posts: n/a
 
      5th Jan 2010

I think you can put below code so the combo box can add item of cell value
in the range of source_list.

For Each cell In Range("source_list").Cells
ComboBox1.AddItem cell.Value
Next



"Brian" wrote:

> I have a User Form that has a combo Box on it. Is it possible for the Combo
> Box to get it's Data from a Work Sheet in the same Work Book as the User Form
> instead of doing in Code as follows:
>
> With Me.Engineer_2
> .AddItem "1"
> .AddItem "2"
> .AddItem "3"
> .AddItem "4"
> .AddItem "5"
> .AddItem "6"
> End With
>
> The reason I ask is because I would like to be able to set it up as follows:
> Combo Box 1 = Customer 1
> Combo Box 2 = State
> Combo Box 3 = Site ID
>
> User Picks the Customer, then the State for that Customer, then the Site ID
> for that Customer.
>
> Each State (9-States) has about 450 Sites for each of the 4 Customers, so
> writing it in Code would take forever. Plus I already have all the Data in a
> Work Book, so all I have to do is add a Sheet for each customer and Copy &
> Paste the Data.
>
> I want to use the Comboxes as a process of elimanation to narrow it down.
>
>

 
Reply With Quote
 
Brian
Guest
Posts: n/a
 
      5th Jan 2010
If you had to do it what would you do it? Would you type some 4000 Names,
Address, State, Zip, etc....?

Would it be better to give each customer there own Module?



"JLGWhiz" wrote:

> The only advantage of using the List or AddItem methods is that you can add
> and delete items from the ComboBox, whereas, if you use the RowSource or
> ListFillRange methods to populate the ComboBox then you cannot add and
> delete items from the ComboBox. When using RowSource and ListFill range,
> the worksheet range has to be modified to change the ComboBox content. That
> said, you can use the RowSource or ListFillRange, as applicable, to populate
> the ComboBox from the same workbook.
>
> In the initialize event for the form:
>
> Me.ComboBox1.RowSource = "Sheet1!A2:A11"
>
> The above code would load data from Range("A2:A11") of sheet 1 in the active
> workbook into the ComboBox1.
>
> To set up the three controls as you have described and use the RowSource
> method, you would need to list your customers in a single colum, the states
> in a single column and the site Id in a single column with empty cells
> purged and each column sorted alpha/numerically for best performance of the
> ComboBox.
>
> If this does not answer the question, then provide more detail.
>
> "Brian" <(E-Mail Removed)> wrote in message
> newsC1DDD5A-97D6-4029-AC33-(E-Mail Removed)...
> >I have a User Form that has a combo Box on it. Is it possible for the Combo
> > Box to get it's Data from a Work Sheet in the same Work Book as the User
> > Form
> > instead of doing in Code as follows:
> >
> > With Me.Engineer_2
> > .AddItem "1"
> > .AddItem "2"
> > .AddItem "3"
> > .AddItem "4"
> > .AddItem "5"
> > .AddItem "6"
> > End With
> >
> > The reason I ask is because I would like to be able to set it up as
> > follows:
> > Combo Box 1 = Customer 1
> > Combo Box 2 = State
> > Combo Box 3 = Site ID
> >
> > User Picks the Customer, then the State for that Customer, then the Site
> > ID
> > for that Customer.
> >
> > Each State (9-States) has about 450 Sites for each of the 4 Customers, so
> > writing it in Code would take forever. Plus I already have all the Data in
> > a
> > Work Book, so all I have to do is add a Sheet for each customer and Copy &
> > Paste the Data.
> >
> > I want to use the Comboxes as a process of elimanation to narrow it down.
> >
> >

>
>
> .
>

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      6th Jan 2010
I would definitely devise a means to avoid typying something that had
already been typed once. But I cannot see what you are working with, have
no idea why you are attempting to do what you are and do not know what
constraints or lattitudes apply, so it presents a problem in determining
exactly what I would do. But, I can nudge you aloing on the code, if you
keep feeding me data.



"Brian" <(E-Mail Removed)> wrote in message
news:9639F69A-75AC-40C6-9A7F-(E-Mail Removed)...
> If you had to do it what would you do it? Would you type some 4000 Names,
> Address, State, Zip, etc....?
>
> Would it be better to give each customer there own Module?
>
>
>
> "JLGWhiz" wrote:
>
>> The only advantage of using the List or AddItem methods is that you can
>> add
>> and delete items from the ComboBox, whereas, if you use the RowSource or
>> ListFillRange methods to populate the ComboBox then you cannot add and
>> delete items from the ComboBox. When using RowSource and ListFill range,
>> the worksheet range has to be modified to change the ComboBox content.
>> That
>> said, you can use the RowSource or ListFillRange, as applicable, to
>> populate
>> the ComboBox from the same workbook.
>>
>> In the initialize event for the form:
>>
>> Me.ComboBox1.RowSource = "Sheet1!A2:A11"
>>
>> The above code would load data from Range("A2:A11") of sheet 1 in the
>> active
>> workbook into the ComboBox1.
>>
>> To set up the three controls as you have described and use the RowSource
>> method, you would need to list your customers in a single colum, the
>> states
>> in a single column and the site Id in a single column with empty cells
>> purged and each column sorted alpha/numerically for best performance of
>> the
>> ComboBox.
>>
>> If this does not answer the question, then provide more detail.
>>
>> "Brian" <(E-Mail Removed)> wrote in message
>> newsC1DDD5A-97D6-4029-AC33-(E-Mail Removed)...
>> >I have a User Form that has a combo Box on it. Is it possible for the
>> >Combo
>> > Box to get it's Data from a Work Sheet in the same Work Book as the
>> > User
>> > Form
>> > instead of doing in Code as follows:
>> >
>> > With Me.Engineer_2
>> > .AddItem "1"
>> > .AddItem "2"
>> > .AddItem "3"
>> > .AddItem "4"
>> > .AddItem "5"
>> > .AddItem "6"
>> > End With
>> >
>> > The reason I ask is because I would like to be able to set it up as
>> > follows:
>> > Combo Box 1 = Customer 1
>> > Combo Box 2 = State
>> > Combo Box 3 = Site ID
>> >
>> > User Picks the Customer, then the State for that Customer, then the
>> > Site
>> > ID
>> > for that Customer.
>> >
>> > Each State (9-States) has about 450 Sites for each of the 4 Customers,
>> > so
>> > writing it in Code would take forever. Plus I already have all the Data
>> > in
>> > a
>> > Work Book, so all I have to do is add a Sheet for each customer and
>> > Copy &
>> > Paste the Data.
>> >
>> > I want to use the Comboxes as a process of elimanation to narrow it
>> > down.
>> >
>> >

>>
>>
>> .
>>



 
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
If excel sheet protected, combo boxes won't work kiwimark Microsoft Excel Misc 2 21st Nov 2008 01:18 AM
Clear a set of combo boxes after a Submit of data to a new sheet. Jonah Microsoft Excel Worksheet Functions 0 3rd Mar 2008 12:05 AM
Combo boxes and lists boxes not showing data Annette Microsoft Access 1 24th Jan 2008 12:50 PM
linked combo boxes in data sheet subform =?Utf-8?B?U2hhbm5vbg==?= Microsoft Access 1 15th Aug 2005 05:28 PM
data access page combo boxes and test boxes not visable or print =?Utf-8?B?Y3RhejJkYXk=?= Microsoft Access 0 26th Jul 2005 02:31 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:53 PM.