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
 
I think it's typo in "WithThisWorkbook.Sheets ("Data")" . Try this one:
Code:
With ThisWorkbook.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
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hi I did that I get a compile error on this line now
Code:
ComboBox2.List = .Range("A2:R" & .Range
 
Upvote 0
Hm, try this:

Code:
With ThisWorkbook.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 that works great thank you for your help on this :)
Please can you advise what the application transpose does please?
 
Upvote 0
Hm, I'm not good at explaining things, you can can just google it.
Basically, in this case, Application.Transpose is used to transform data in column to row.
Range B1:R1 is multi column whilst you need the value in a single column (multi row) combobox. So you need to transform it to row .
 
Upvote 0
You're welcome, glad to help, & thanks for the feedback.:)
 
Upvote 0

Forum statistics

Threads
1,215,005
Messages
6,122,661
Members
449,091
Latest member
peppernaut

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