ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Combine a combobox with logic (https://www.excelbanter.com/excel-discussion-misc-queries/203335-combine-combobox-logic.html)

THill

Combine a combobox with logic
 
Is there a way to program excel to pull a specifec list based on a cells
value ie. if a1 = 1 pull data for combox from list 1, if a1 = 2 pull data
from list 2 ect, ect

FSt1

Combine a combobox with logic
 
hi
yes
you can use the gotfocus event to set the listfillrange of a sheet combo box
but your list have to be on the sheet somewhere.
example
Private Sub ComboBox1_GotFocus()
If Range("A1").Value = 1 Then
ComboBox1.ListFillRange = "G1:G5"
Else
If Range("A1").Value = 2 Then
ComboBox1.ListFillRange = "H1:H5"
Else
ComboBox1.ListFillRange = "I1:I5"
End If
End If
End Sub
with a form combo box(ON A FORM, NOT THE SHEET), i think it's the row source.
you can also use the additem method. look that up in vb help.

Regards
FSt1


"THILL" wrote:

Is there a way to program excel to pull a specifec list based on a cells
value ie. if a1 = 1 pull data for combox from list 1, if a1 = 2 pull data
from list 2 ect, ect


Dave Peterson

Combine a combobox with logic
 
If your combobox is placed on a worksheet, maybe you could replace them with
cells with Data|Validation.

Then use the instructions at Debra Dalgleish's site:
http://contextures.com/xlDataVal02.html

THILL wrote:

Is there a way to program excel to pull a specifec list based on a cells
value ie. if a1 = 1 pull data for combox from list 1, if a1 = 2 pull data
from list 2 ect, ect


--

Dave Peterson


All times are GMT +1. The time now is 04:27 PM.

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