View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jake Marx[_3_] Jake Marx[_3_] is offline
external usenet poster
 
Posts: 860
Default Could You Explain the difference?

Hi Jose,

jose luis wrote:
Can you help understand why this code works:
--------------------
Sheets(1).Shapes("ComboBoxA").Select
Selection.ListFillRange = "lista2"
--------------------

and this one don't:
--------------------
Sheets(1).Shapes("ComboBoxA").ListFillRange = "lista2"
--------------------


Sheets(1).Shapes("ComboBoxA") is an object of type "Shape". Thus, there is
no ListFillRange property available. When you first Select the object, then
Selection refers to the actual "DropDown" object, which does have a
ListFillRange property available. So that's why selecting it first works.

Another option is to use the OLEFormat and Object properties to get a
reference to the actual object type:

Sheets(1).Shapes("ComboBoxA").OLEFormat.Object.Lis tFillRange = "lista2"

Or you can use the DropDowns collection:

Sheets(1).DropDowns("ComboBoxA").ListFillRange = "lista2"

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]