通过Excel下拉列表/验证列表迭代 [英] Iterate through an Excel dropdown/validation list

查看:142
本文介绍了通过Excel下拉列表/验证列表迭代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有验证列表的单元格,具体取决于其他设置。是否可以在代码中迭代该单元格?
也可以将该单元格设置为列表中的第n个项目?

I have a cell with a validation list that changes depending on other settings. Is it possible to iterate through that cell in code? Is it also possible to set that cell to the nth item in the list?

示例:

E2的下拉菜单取决于所选的D2。我希望能够遍历E2中的任何列表,而无需检查D2。

Example: The drop down for E2 depends on what was selected for D2. I would like to be able to iterate through whatever list is in E2 without having to check D2.

谢谢。

推荐答案

这将适用于您

Sub loopthroughvalidationlist()
     Dim inputRange As Range
     Dim c As Range
     Set inputRange = Evaluate(Range("D2").Validation.Formula1)
     For Each c In inputRange
        '... do something with c.Value
    Next c
End Sub

这篇关于通过Excel下拉列表/验证列表迭代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆