ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ComboBox with horizontal range on an Excel USERFORM (https://www.excelbanter.com/excel-programming/350950-combobox-horizontal-range-excel-userform.html)

ca1358

ComboBox with horizontal range on an Excel USERFORM
 
How do you write a source in code in VB Code for a ComboBox3 on an Excel
UserForm where the source is horizontal range. For example Sheet2!E2:H2.
--
ca1358

Dave Peterson

ComboBox with horizontal range on an Excel USERFORM
 
dim myCell as range
dim myRng as range

set myrng = worksheets("sheet2").range("e2:h2")

With me.combobox3
for each mycell in myrng.cells
.additem mycell.value
next mycell
end with


ca1358 wrote:

How do you write a source in code in VB Code for a ComboBox3 on an Excel
UserForm where the source is horizontal range. For example Sheet2!E2:H2.
--
ca1358


--

Dave Peterson

Andy Pope

ComboBox with horizontal range on an Excel USERFORM
 
Hi,

If it's just the contents of the cells required to populate the control
and not be linked then perhaps,

ComboBox1.List = _
Application.WorksheetFunction.Transpose( _
Worksheets("sheet2").Range("e2:h2"))

Cheers
Andy

ca1358 wrote:
How do you write a source in code in VB Code for a ComboBox3 on an Excel
UserForm where the source is horizontal range. For example Sheet2!E2:H2.


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info

ca1358

ComboBox with horizontal range on an Excel USERFORM
 
Thank you!!!!!!!!!!!!
--
ca1358


"Dave Peterson" wrote:

dim myCell as range
dim myRng as range

set myrng = worksheets("sheet2").range("e2:h2")

With me.combobox3
for each mycell in myrng.cells
.additem mycell.value
next mycell
end with


ca1358 wrote:

How do you write a source in code in VB Code for a ComboBox3 on an Excel
UserForm where the source is horizontal range. For example Sheet2!E2:H2.
--
ca1358


--

Dave Peterson



All times are GMT +1. The time now is 08:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com