L
Little Penny
I'm trying to use the same form for multi column combo box for 10
columns. I have started with two Column L and Column N. If I reference
this line of code
If ActiveCell.Address = Range("L25:L39").Address Then as
If ActiveCell.Address = Range("L25").Address
And
If ActiveCell.Address = Range("N25:N39").Address Then as
If ActiveCell.Address = Range("N25").Address
Then the code works but only for that cell. I want the for to load
with the list if any cell from L25:L39 is selected. There are two
works sheet selection events to call the user form
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("L25:L39")) Is Nothing Then
Call aaa
End If
If Not Intersect(Target, Range("N25:N39")) Is Nothing Then
Call aaa
End If
End sub
Here id my code
Private Sub UserForm_activate()
Dim MyList(10, 10) 'as array type
If ActiveCell.Address = Range("L25:L39").Address Then
With ComboBox1
.ColumnCount = 2
.ColumnWidths = "60,80"
.Width = 240
.Height = 15
.ListRows = 6
End With
With ActiveSheet
MyList(0, 0) = .Range("A201")
MyList(1, 0) = .Range("A202")
MyList(2, 0) = .Range("A203")
MyList(3, 0) = .Range("A204")
MyList(4, 0) = .Range("A205")
MyList(5, 0) = .Range("A206")
MyList(6, 0) = .Range("A207")
MyList(7, 0) = .Range("A208")
MyList(8, 0) = .Range("A209")
MyList(9, 0) = .Range("A210")
'//MyList (Row{0 to 9}, Column{second}) = (Column D in this
example)
MyList(0, 1) = .Range("B201")
MyList(1, 1) = .Range("B202")
MyList(2, 1) = .Range("B203")
MyList(3, 1) = .Range("B204")
MyList(4, 1) = .Range("B205")
MyList(5, 1) = .Range("B206")
MyList(6, 1) = .Range("B207")
MyList(7, 1) = .Range("B208")
MyList(8, 1) = .Range("B209")
MyList(9, 1) = .Range("B210")
End With
'//now populate the combo box
ComboBox1.List() = MyList
End If
'*****************************************************************
If ActiveCell.Address = Range("N25:N39").Address Then
With ComboBox1
.ColumnCount = 2
.ColumnWidths = "60,80"
.Width = 240
.Height = 15
.ListRows = 6
End With
With ActiveSheet
MyList(0, 0) = .Range("J201")
MyList(1, 0) = .Range("J202")
MyList(2, 0) = .Range("J203")
MyList(3, 0) = .Range("J204")
MyList(4, 0) = .Range("J205")
MyList(5, 0) = .Range("J206")
MyList(6, 0) = .Range("J207")
MyList(7, 0) = .Range("J208")
MyList(8, 0) = .Range("J209")
MyList(9, 0) = .Range("J210")
MyList(0, 1) = .Range("K201")
MyList(1, 1) = .Range("K202")
MyList(2, 1) = .Range("K203")
MyList(3, 1) = .Range("K204")
MyList(4, 1) = .Range("K205")
MyList(5, 1) = .Range("K206")
MyList(6, 1) = .Range("K207")
MyList(7, 1) = .Range("K208")
MyList(8, 1) = .Range("K209")
MyList(9, 1) = .Range("K210")
End With
ComboBox1.List() = MyList
End If
'*****************************************************************
'//The combo box in this example contains 3 data columns
End Sub
Thanks
Little Penny
columns. I have started with two Column L and Column N. If I reference
this line of code
If ActiveCell.Address = Range("L25:L39").Address Then as
If ActiveCell.Address = Range("L25").Address
And
If ActiveCell.Address = Range("N25:N39").Address Then as
If ActiveCell.Address = Range("N25").Address
Then the code works but only for that cell. I want the for to load
with the list if any cell from L25:L39 is selected. There are two
works sheet selection events to call the user form
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("L25:L39")) Is Nothing Then
Call aaa
End If
If Not Intersect(Target, Range("N25:N39")) Is Nothing Then
Call aaa
End If
End sub
Here id my code
Private Sub UserForm_activate()
Dim MyList(10, 10) 'as array type
If ActiveCell.Address = Range("L25:L39").Address Then
With ComboBox1
.ColumnCount = 2
.ColumnWidths = "60,80"
.Width = 240
.Height = 15
.ListRows = 6
End With
With ActiveSheet
MyList(0, 0) = .Range("A201")
MyList(1, 0) = .Range("A202")
MyList(2, 0) = .Range("A203")
MyList(3, 0) = .Range("A204")
MyList(4, 0) = .Range("A205")
MyList(5, 0) = .Range("A206")
MyList(6, 0) = .Range("A207")
MyList(7, 0) = .Range("A208")
MyList(8, 0) = .Range("A209")
MyList(9, 0) = .Range("A210")
'//MyList (Row{0 to 9}, Column{second}) = (Column D in this
example)
MyList(0, 1) = .Range("B201")
MyList(1, 1) = .Range("B202")
MyList(2, 1) = .Range("B203")
MyList(3, 1) = .Range("B204")
MyList(4, 1) = .Range("B205")
MyList(5, 1) = .Range("B206")
MyList(6, 1) = .Range("B207")
MyList(7, 1) = .Range("B208")
MyList(8, 1) = .Range("B209")
MyList(9, 1) = .Range("B210")
End With
'//now populate the combo box
ComboBox1.List() = MyList
End If
'*****************************************************************
If ActiveCell.Address = Range("N25:N39").Address Then
With ComboBox1
.ColumnCount = 2
.ColumnWidths = "60,80"
.Width = 240
.Height = 15
.ListRows = 6
End With
With ActiveSheet
MyList(0, 0) = .Range("J201")
MyList(1, 0) = .Range("J202")
MyList(2, 0) = .Range("J203")
MyList(3, 0) = .Range("J204")
MyList(4, 0) = .Range("J205")
MyList(5, 0) = .Range("J206")
MyList(6, 0) = .Range("J207")
MyList(7, 0) = .Range("J208")
MyList(8, 0) = .Range("J209")
MyList(9, 0) = .Range("J210")
MyList(0, 1) = .Range("K201")
MyList(1, 1) = .Range("K202")
MyList(2, 1) = .Range("K203")
MyList(3, 1) = .Range("K204")
MyList(4, 1) = .Range("K205")
MyList(5, 1) = .Range("K206")
MyList(6, 1) = .Range("K207")
MyList(7, 1) = .Range("K208")
MyList(8, 1) = .Range("K209")
MyList(9, 1) = .Range("K210")
End With
ComboBox1.List() = MyList
End If
'*****************************************************************
'//The combo box in this example contains 3 data columns
End Sub
Thanks
Little Penny