Can't select ComboBox item

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
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,223,277
Messages
6,171,147
Members
452,382
Latest member
RonChand

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top