dynamic构build下拉列表?

我需要dynamic构build一个下拉列表,在input特定文本到一个单元格后,我执行一些SQL,并从返回的行中构build一个Dropdown

事件如何集中在一个单元(而不是整个电子表格)的价值?

我必须在创buildDropdown之前将SQL行值“粘贴”到电子表格中? 是不是可以在VBA中填充Dropdown而不必将值粘贴到电子表格上,然后突出显示它们来创buildDropdown

谢谢

不,不需要在工作表中粘贴值来创build下拉菜单。 看到这个例子

 Option Explicit Sub Sample() Dim dvList As String '~~> You can construct this list from your database dvList = "Option1, Option2, Option3" '~~> Creates the list in Sheet1, A1 With Sheets("Sheet1").Range("A1").Validation .Delete .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _ xlBetween, Formula1:=dvList .IgnoreBlank = True .InCellDropdown = True .InputTitle = "" .ErrorTitle = "" .InputMessage = "" .ErrorMessage = "" .ShowInput = True .ShowError = True End With End Sub