Problem with setting the ListFillRange in VBA

  • Thread starter Thread starter spacecityguy
  • Start date Start date
S

spacecityguy

Hi,

As an experiment, I opened a blank sheet and added a combo box usin
the Control Toolbox. I named this combo box cboList. I then add
button and this code to it:

activesheet.shapes("cboList").controlformat.listfillrange = "A1:A10"

When I ran the code, I got this error:

"Object doesn't support this property or method."

I looked up a few books on VBA for Excel programming as well as Exce
Help but got little help from them. This seems to be a very trivia
matter, and I don't know what else to try. I'll appreciate if anybod
can explain it to me.

Eventually, I would like to be able to read a list of values from th
database (using the add-in provided by the database) and assign a nam
to this list and then use the name for the listfillrange of my comb
box. I don't really need to use a name, but it'll make the rang
available in other parts of my application. I built eveyrthing already
The last hurdle I needed to get through is setting the listfillrang
using code.

Thanks for reading,
spacecitygu
 
Instead of following Excel help to refer to my listfillrange as below:

worksheets(i).shapes(i).controlformat.listfillrange = "R1C1"

which kept giving me the "object not defined" error.

I found out this will work:

worksheets(i).[name of my list box].listfillrange = "R1C1"

Sometimes I just don't understand how the object/class/property work
in VBA for Excel.

spacecitygu
 
I failed to recognize the difference between ActiveX controls and M
Excel Form Controls
 
Back
Top