Trying to Replace a Combo Box with a List Box (Form Control) in Excel Worksheet

nryan

Board Regular
Joined
Apr 3, 2015
Messages
61
Hello,

I'm working with an excel worksheet with macros and there are several Combo Boxes (Form Control) on one worksheet. Most of these Combo Boxes have only 2 items to choose from so I thought it would be nicer to have List Boxes to replace them.

I started by trying to replace just one combo box with a list box. I added a Form Control List Box to the same worksheet (right underneath the combo box) and called it "listCxN". I also assigned it the same input range and the combo box it is replacing.

Here is the VBA code:

Original (using Combo Boxes):

HTML:
Dim CN As DropDown
Set CN = Instructions.DropDowns("ddCxN")
Set r = Master.Range(CN.ListFillRange)

What I've changed it to (using List Boxes):

HTML:
Dim CN As ListBox
Set CN = Instructions.DropDowns("listCxN")
Set r = Master.Range(CN.ListFillRange)

The error I get is Run-time error '1004': The item with the specified name wasn't found. The list box called "listCxN" is definitely there and is spelled correctly so I don't know how this error is happening. Do I need to do something in the workbook or worksheet that wouldn't be in the VBA Macro code? I tried [Right-Click] on List Box > "Assign Macro..." and chose the macro, but that didn't fix it.

Any help or insight would be great!

Thank you.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Try...

Code:
Set CN = Instructions.[COLOR=#ff0000]ListBoxes[/COLOR]("listCxN")

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,215,006
Messages
6,122,666
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