Hi If the answer is posted elsewhere then I apologise and please direct me, I have tried some similar answers but unable to get them to work with what I am trying to do.
I have a user form that opens where you first select from a drop down either Elec, Plumb or Build..(created as a named group on sheet1), this then displays in a second drop down the list of each group, i.e. if Elec is selected in dropdown 1 then Elec1, Elec2, Elec3 is displayed in drop down 2 and when one of these is selected the address etc. is displayed in remaining boxes.
This all works fine but Elec1, Elec2, etc. are only done as a group name off sheet1 and what I would like to do is have it so that when Elec is selected in drop down 1, drop down 2 displays everything from column 2 that has the tag of "E" in column 1, this way when I add to the list I just need to tag it with "E" or "B" etc and not keep extending the groupname.
Sheet 1 is as below Elec1, Elec2, Elec3 etc. is grouped with name Elec and same with Plumb1 etc.
<tbody>
</tbody><strike></strike>
The code on the UserForm is as follows:
I suppose what I am looking for is some way in which to say,
Select Case x
Case Is = 0
ComboBox2.RowSource = "Everything from column 2 where column 1 is E"
<strike></strike>Case Is = 1
ComboBox2.RowSource = "Everything from column 2 where column 1 is P"
I hope this makes sense.
<strike></strike>
I have a user form that opens where you first select from a drop down either Elec, Plumb or Build..(created as a named group on sheet1), this then displays in a second drop down the list of each group, i.e. if Elec is selected in dropdown 1 then Elec1, Elec2, Elec3 is displayed in drop down 2 and when one of these is selected the address etc. is displayed in remaining boxes.
This all works fine but Elec1, Elec2, etc. are only done as a group name off sheet1 and what I would like to do is have it so that when Elec is selected in drop down 1, drop down 2 displays everything from column 2 that has the tag of "E" in column 1, this way when I add to the list I just need to tag it with "E" or "B" etc and not keep extending the groupname.
Sheet 1 is as below Elec1, Elec2, Elec3 etc. is grouped with name Elec and same with Plumb1 etc.
A | B | C | D | E | |
1 | Tag | Name | Number | Address | Post Code |
2 | E | Elec 1 | 0844 | Address One | PC1 |
3 | E | Elec 2 | 0845 | Address Two | PC2 |
4 | E | Elec 3 | 0846 | Address Three | PC3 |
5 | P | Plumb1 | 0847 | Address Four | PC4 |
6 | P | Plumb2 | 0848 | Address Five | PC5 |
7 | P | Plumb3 | 0849 | Address Six | PC6 |
8 | B | Build1 | 0850 | Address Seven | PC7 |
9 | B | Build2 | 0851 | Address Eight | PC8 |
10 | B | Build3 | 0852 | Address Nine | PC9 |
11 | |||||
12 | |||||
13 | Elec | ||||
14 | Plumb | ||||
15 | Build |
<tbody>
</tbody>
The code on the UserForm is as follows:
Code:
Private Sub ComboBox1_Change()
Dim x As Integer
x = ComboBox1.ListIndex
Select Case x
Case Is = 0
ComboBox2.RowSource = "Elec"
Case Is = 1
ComboBox2.RowSource = "Plum"
Case Is = 2
ComboBox2.RowSource = "Build"
End Select
End Sub
Private Sub ComboBox2_Change()
Dim dd_name As String
Dim Lookup_Range As Range
Dim Name As Single
dd_name = ComboBox2.Text
Set Lookup_Range = Range("chart")
Name = Application.WorksheetFunction.VLookup(dd_name, Lookup_Range, 2, False)
Address = Application.WorksheetFunction.VLookup(dd_name, Lookup_Range, 3, False)
Post_Code = Application.WorksheetFunction.VLookup(dd_name, Lookup_Range, 4, False)
TextBox1.Text = Name
TextBox2.Text = Address
TextBox3.Text = Post_Code
End Sub
Private Sub CommandButton1_Click()
ClearForm
End Sub
I suppose what I am looking for is some way in which to say,
Select Case x
Case Is = 0
ComboBox2.RowSource = "Everything from column 2 where column 1 is E"
<strike></strike>Case Is = 1
ComboBox2.RowSource = "Everything from column 2 where column 1 is P"
I hope this makes sense.
<strike></strike>