ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ControlFormat Problem (https://www.excelbanter.com/excel-programming/384091-controlformat-problem.html)

equiangular

ControlFormat Problem
 
Sub test()
Dim cf As ControlFormat
Set cf = Worksheets("sheet1").Shapes("Drop Down 1").ControlFormat
cf.List = Array("a", "b") ' <-- error line
End Sub


The code works perfectly if i use Worksheets("sheet1").Shapes("Drop Down
1").ControlFormat.List = Array("a", "b").

Why this is so?

Thanks.

Doug Glancy[_7_]

ControlFormat Problem
 
When I F1 over ControlFormat it seems that it's both a Property and an
Object, which has something to do with why one case works and the other
doesn't, I think.

How about this instead?:

Sub test()
Dim dd As DropDown
Set dd = Worksheets("sheet1").DropDowns("Drop Down 1")
dd.List = Array("a", "b") ' <-- error line
End Sub

hth,

Doug

"equiangular" wrote in message
...
Sub test()
Dim cf As ControlFormat
Set cf = Worksheets("sheet1").Shapes("Drop Down 1").ControlFormat
cf.List = Array("a", "b") ' <-- error line
End Sub


The code works perfectly if i use Worksheets("sheet1").Shapes("Drop Down
1").ControlFormat.List = Array("a", "b").

Why this is so?

Thanks.




equiangular

ControlFormat Problem
 
It seems that ControlFormat is a special case.

Thanks a lot.

Doug Glancy wrote:
When I F1 over ControlFormat it seems that it's both a Property and an
Object, which has something to do with why one case works and the other
doesn't, I think.

How about this instead?:

Sub test()
Dim dd As DropDown
Set dd = Worksheets("sheet1").DropDowns("Drop Down 1")
dd.List = Array("a", "b") ' <-- error line
End Sub

hth,

Doug

"equiangular" wrote in message
...
Sub test()
Dim cf As ControlFormat
Set cf = Worksheets("sheet1").Shapes("Drop Down 1").ControlFormat
cf.List = Array("a", "b") ' <-- error line
End Sub


The code works perfectly if i use Worksheets("sheet1").Shapes("Drop Down
1").ControlFormat.List = Array("a", "b").

Why this is so?

Thanks.





All times are GMT +1. The time now is 03:13 PM.

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