无法使用VBA将所有下拉值从ui拉到excel

时间:2015-08-29 13:13:05

标签: excel vba excel-vba drop-down-menu

以下是将所选下拉列表值拉入excel的代码。但我想拉下该下拉列表的所有值。请帮助我,并提前感谢。

Array
(
    [green]  => avocado
    [red]    => apple
    [yellow] => banana
)

1 个答案:

答案 0 :(得分:1)

Dim x As Long

x = TypeOfChange.Options.Length

'Options is zero-based, so need to count from 0 to x-1
For i = 0 to x-1
    Sheet1.Cells(i+1, "A").Value = TypeOfChange.Options(i).Text
    'if you need the value for the option...
    Sheet1.Cells(i+1, "B").Value = TypeOfChange.Options(i).Value
Next