Naming Range for Combobox specifically

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,227
Office Version
  1. 2010
Platform
  1. Windows
Hi please can you help me,
I have the code below where combobox2 is working fine, butwith combobox1 I want the range to be B1, C1, D1, E1, F1, G1, H1, J1, K1, L1,M1, N1, O1, P1, Q1, R1, please can you help?


Code:
With ThisWorkbook.Sheets("Data")
    ComboBox1.RowSource = ""
    ComboBox1.List = .Range("B1:R" & .Range("B" & Rows.Count).End(xlUp).Row).Value
    ComboBox2.RowSource = ""
    ComboBox2.List = .Range("A2:R" & .Range("A" & Rows.Count).End(xlUp).Row).Value

End With
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hi I have tried changing it to the below as well but this didn't work. hope you can help.
Code:
[FONT=Times New Roman][SIZE=3][COLOR=#000000][/COLOR][/SIZE][/FONT][COLOR=#222222][FONT=Calibri][FONT=Calibri]WithThisWorkbook.Sheets("Data")
    ComboBox1.RowSource = ""
    ComboBox1.List = .Range("B1, C1, D1, E1, F1, G1, H1,J1, K1, L1,M1, N1, O1, P1, Q1, R1").Value
    ComboBox2.RowSource = ""
    ComboBox2.List = .Range("A2:R" &.Range("A" & Rows.Count).End(xlUp).Row).Value

End With[/FONT][/FONT][/COLOR]
[FONT=Times New Roman][SIZE=3][COLOR=#000000][/CO[/COLOR][/SIZE][/FONT]DE]
 
Upvote 0
Are both of these Multicolumn ComboBoxes?
And what type ComboBox
Form
Activex

Or Userform
 
Last edited:
Upvote 0
What do you mean? each combobox has a list for example combobox1 has a lit of 18 items and combobox has a list f 18 items, combobox2 to was a1 to a18 an and combobox1 is b2 to r18, in sheet called 'Data'

they are both in a userform
 
Last edited:
Upvote 0
ComboBox1.List = .Range("B1, C1, D1, E1, F1, G1, H1,J1, K1, L1,M1, N1, O1, P1, Q1, R1").Value
Do you mean range B1:R1 without I1?

And is it a single column or multiple column combobox?
 
Last edited:
Upvote 0
Hi yes B1:R1, I have data in I1 as well.

I think with your second question it is singlecolumn, I only have dates in B1:R1 which I want to go into combobox1
 
Upvote 0
Code:
Hi yes B1:R1, I have data in I1 as well.
Ok, so range B1:R1 (including I1).
1 column combobox means range B1:R1 becomes the rows ( not columns) of the list in the combobox.
Try this:

Code:
WithThisWorkbook.Sheets ("Data")
ComboBox1.RowSource = ""
ComboBox1.List = Application.Transpose(.Range("B1:R1").Value)
ComboBox2.RowSource = ""
ComboBox2.List = .Range("A2:R" & .Range("A" & Rows.Count).End(xlUp).Row).Value
End With
 
Upvote 0
Hi thank you for the code but I get a compile error on the snippet below.
Code:
Transpose(.Range
 
Upvote 0
Change it to this:
Code:
ComboBox1.RowSource = ""
ComboBox1.List = Application.Transpose(Range("B1:R1").Value)
 
Upvote 0

Forum statistics

Threads
1,214,946
Messages
6,122,401
Members
449,081
Latest member
JAMES KECULAH

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