rutgerterhaar
New Member
- Joined
- Jan 21, 2012
- Messages
- 18
Hi there!
I want to make a Combobox with the input from two columns (Range("M2:N11")) and those have to be sepreatly shown in the ComboBox (columncount =2). I'm a beginner in VBA, so I searched the forum and I have made the following code. This code generates a ComboBox in sheet2 with data (only integers) from sheet1.
Private Sub ComboBox1_Change()
Dim MyArray()
With Sheets("Sheet1").Range("M2:N11")
'set the bounds of your array
ReDim MyArray(1 To .Rows.count, 1 To .Columns.count)
'fill array with range
MyArray = Sheets("Sheet2").Range("M2:N11").Value
End With
ComboBox1.Clear
With ComboBox1
.ColumnCount = 2
.ColumnWidths = 50
.ListWidth = 100
.ListRows = 6
.List = MyArray()
End With
End Sub
The problem:
The ComboBox is filled with the data and it shows the data in two columns. But I can't select no data. Maybe it's versy simple, but I can't figure it out .
And I want to put the selected integer in the ComboBox to be placed in Sheet1. How does that work? It's probably also simple.
Hope this is enough information.
Thanks!!
Rutger
I want to make a Combobox with the input from two columns (Range("M2:N11")) and those have to be sepreatly shown in the ComboBox (columncount =2). I'm a beginner in VBA, so I searched the forum and I have made the following code. This code generates a ComboBox in sheet2 with data (only integers) from sheet1.
Private Sub ComboBox1_Change()
Dim MyArray()
With Sheets("Sheet1").Range("M2:N11")
'set the bounds of your array
ReDim MyArray(1 To .Rows.count, 1 To .Columns.count)
'fill array with range
MyArray = Sheets("Sheet2").Range("M2:N11").Value
End With
ComboBox1.Clear
With ComboBox1
.ColumnCount = 2
.ColumnWidths = 50
.ListWidth = 100
.ListRows = 6
.List = MyArray()
End With
End Sub
The problem:
The ComboBox is filled with the data and it shows the data in two columns. But I can't select no data. Maybe it's versy simple, but I can't figure it out .
And I want to put the selected integer in the ComboBox to be placed in Sheet1. How does that work? It's probably also simple.
Hope this is enough information.
Thanks!!
Rutger