我有一个小宏,可以在单元格 B2
中建立数据验证下拉菜单Sub InternalString()
Range("B2").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="alpha,beta,gamma,delta"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End Sub
宏也选择 s单元格。我想在宏中添加一些内容,然后点击"在下拉菜单中,一旦控件返回给用户,他们就会看到:
欢迎任何建议。
答案 0 :(得分:1)
根据建议here进行修改,似乎SendKeys
应该可以解决问题:
Sub InternalString()
Range("B2").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="alpha,beta,gamma,delta"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
'"Show" the validation list as a dropdown:
Application.SendKeys ("%{DOWN}")
End Sub