ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Set RowSource (https://www.excelbanter.com/excel-programming/438064-set-rowsource.html)

ordnance1[_2_]

Set RowSource
 
Is it possible to set the RowSource for a ComboBox based on a condition?

For ComboBox1 I would like to set the RowSource as follows:

If ActiveWorkbook.Worksheets("FR Launch Sheet").Range("B3") = Sat then
Rowsource would be 'Routes'!$E$2:$E$61

If ActiveWorkbook.Worksheets("FR Launch Sheet").Range("B3") = Sun then
Rowsource would be 'Routes'!$H$2:$H$61

If ActiveWorkbook.Worksheets("FR Launch Sheet").Range("B3") did not equal
Sat or Sun then Rowsource would be 'Routes'!$B$2:$B$61



Per Jessen[_2_]

Set RowSource
 
Hi

It can be done like this:

Select Case ActiveWorkbook.Worksheets("FR Launch Sheet").Range("B3")
Case "Sat"
Me.ComboBox1.RowSource = "'Routes'!$E$2:$E$61"
Case "Sun"
Me.ComboBox1.RowSource = "'Routes'!$H$2:$H$61"
Case Else
Me.ComboBox1.RowSource = "'Routes'!$B$2:$B$61"
End Select

Regards,
Per


On 6 Jan., 20:17, "ordnance1" wrote:
Is it possible to set the RowSource for a ComboBox based on a condition?

For ComboBox1 I would like to set the RowSource as follows:

If ActiveWorkbook.Worksheets("FR Launch Sheet").Range("B3") = Sat then
Rowsource would be *'Routes'!$E$2:$E$61

If ActiveWorkbook.Worksheets("FR Launch Sheet").Range("B3") = Sun then
Rowsource would be *'Routes'!$H$2:$H$61

If ActiveWorkbook.Worksheets("FR Launch Sheet").Range("B3") did not equal
Sat or Sun then Rowsource would be *'Routes'!$B$2:$B$61



ordnance1[_2_]

Set RowSource
 
Thanks for the help

"Per Jessen" wrote in message
...
Hi

It can be done like this:

Select Case ActiveWorkbook.Worksheets("FR Launch Sheet").Range("B3")
Case "Sat"
Me.ComboBox1.RowSource = "'Routes'!$E$2:$E$61"
Case "Sun"
Me.ComboBox1.RowSource = "'Routes'!$H$2:$H$61"
Case Else
Me.ComboBox1.RowSource = "'Routes'!$B$2:$B$61"
End Select

Regards,
Per


On 6 Jan., 20:17, "ordnance1" wrote:
Is it possible to set the RowSource for a ComboBox based on a condition?

For ComboBox1 I would like to set the RowSource as follows:

If ActiveWorkbook.Worksheets("FR Launch Sheet").Range("B3") = Sat then
Rowsource would be 'Routes'!$E$2:$E$61

If ActiveWorkbook.Worksheets("FR Launch Sheet").Range("B3") = Sun then
Rowsource would be 'Routes'!$H$2:$H$61

If ActiveWorkbook.Worksheets("FR Launch Sheet").Range("B3") did not equal
Sat or Sun then Rowsource would be 'Routes'!$B$2:$B$61



Ryan H

Set RowSource
 
I will assume that Combobox1 is located on a Userform. If that is the case,
put this in the Userforms Intialize Event. Hope this helps! If so, let me
know, click "YES" below.

Private Sub UserForm_Initialize()

Select Case ActiveWorkbook.Worksheets("FR Launch Sheet").Range("B3").Value

Case Is = "Sat"
Me.ComboBox1.RowSource = "'Routes'!$E$2:$E$61"
Case Is = "Sun"
Me.ComboBox1.RowSource = "'Routes'!$H$2:$H$61"
Case Else
Me.ComboBox1.RowSource = "'Routes'!$B$2:$B$61"
End Select

End Sub
--
Cheers,
Ryan


"ordnance1" wrote:

Is it possible to set the RowSource for a ComboBox based on a condition?

For ComboBox1 I would like to set the RowSource as follows:

If ActiveWorkbook.Worksheets("FR Launch Sheet").Range("B3") = Sat then
Rowsource would be 'Routes'!$E$2:$E$61

If ActiveWorkbook.Worksheets("FR Launch Sheet").Range("B3") = Sun then
Rowsource would be 'Routes'!$H$2:$H$61

If ActiveWorkbook.Worksheets("FR Launch Sheet").Range("B3") did not equal
Sat or Sun then Rowsource would be 'Routes'!$B$2:$B$61


.



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

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