ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   combobox.ListFillRangeTrouble in VBA (https://www.excelbanter.com/excel-programming/435714-combobox-listfillrangetrouble-vba.html)

DogLover

combobox.ListFillRangeTrouble in VBA
 
I am trying to use 2 different Listfill Ranges in a combo box depending on
whether a check box is true or false. The code blows up on the last line of
code ComboBoxDept.ListFillRange = NewFillRange. Can anyone help me figure
out what I'm doing wrong?


Dim NewFillRange As Range
If CheckBoxEntity.Value = True Then Set NewFillRange =
Worksheets("Demo").Range("DemoDeptByEntity")
If CheckBoxEntity.Value = False Then Set NewFillRange =
Worksheets("Demo").Range("DemoDept")
ComboBoxDept.ListFillRange = NewFillRange

joel[_168_]

combobox.ListFillRangeTrouble in VBA
 

Try these changes

Dim NewFillRange As Range
If CheckBoxEntity.Value = True Then
Set NewFillRange = Worksheets("Demo").Range("DemoDeptByEntity")
Else
Set NewFillRange = Worksheets("Demo").Range("DemoDept")
end if
ComboBoxDept.ListFillRange = NewFillRange


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=150356

Microsoft Office Help


JLGWhiz[_2_]

combobox.ListFillRangeTrouble in VBA
 
Try it this way:

Dim NewFillRange As Range
If CheckBoxEntity.Value = True Then
Set NewFillRange = Worksheets("Demo").Range("DemoDeptByEntity")
Else
Set NewFillRange = Worksheets("Demo").Range("DemoDept")
End If
ComboBoxDept.ListFillRange = NewFillRange





"DogLover" wrote in message
...
I am trying to use 2 different Listfill Ranges in a combo box depending on
whether a check box is true or false. The code blows up on the last line
of
code ComboBoxDept.ListFillRange = NewFillRange. Can anyone help me figure
out what I'm doing wrong?


Dim NewFillRange As Range
If CheckBoxEntity.Value = True Then Set NewFillRange =
Worksheets("Demo").Range("DemoDeptByEntity")
If CheckBoxEntity.Value = False Then Set NewFillRange =
Worksheets("Demo").Range("DemoDept")
ComboBoxDept.ListFillRange = NewFillRange




FSt1

combobox.ListFillRangeTrouble in VBA
 
hi
not sure but excel may think you are trying to assign the values of your
named ranges to the listfillrange. you may be getting a type mismatch error.
guessing.
try this......

ComboBoxDept.ListFillRange = NewFillRange.Address

regards
FSt1

"DogLover" wrote:

I am trying to use 2 different Listfill Ranges in a combo box depending on
whether a check box is true or false. The code blows up on the last line of
code ComboBoxDept.ListFillRange = NewFillRange. Can anyone help me figure
out what I'm doing wrong?


Dim NewFillRange As Range
If CheckBoxEntity.Value = True Then Set NewFillRange =
Worksheets("Demo").Range("DemoDeptByEntity")
If CheckBoxEntity.Value = False Then Set NewFillRange =
Worksheets("Demo").Range("DemoDept")
ComboBoxDept.ListFillRange = NewFillRange


Dave Peterson

combobox.ListFillRangeTrouble in VBA
 
I bet that checkboxentity is set to be checked or unchecked. (You're not using
triplestate = true).

Dim NewFillRange As Range
If me.CheckBoxEntity.Value = True Then
Set NewFillRange = Worksheets("Demo").Range("DemoDeptByEntity")
else 'it has to be false
Set NewFillRange = Worksheets("Demo").Range("DemoDept")
end if
me.ComboBoxDept.ListFillRange = NewFillRange.address(external:=true)





DogLover wrote:

I am trying to use 2 different Listfill Ranges in a combo box depending on
whether a check box is true or false. The code blows up on the last line of
code ComboBoxDept.ListFillRange = NewFillRange. Can anyone help me figure
out what I'm doing wrong?

Dim NewFillRange As Range
If CheckBoxEntity.Value = True Then Set NewFillRange =
Worksheets("Demo").Range("DemoDeptByEntity")
If CheckBoxEntity.Value = False Then Set NewFillRange =
Worksheets("Demo").Range("DemoDept")
ComboBoxDept.ListFillRange = NewFillRange


--

Dave Peterson


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

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