我的Excel工作表中有一个下拉表单控件。它的输入范围是一个命名范围,它包含另一个命名范围。我希望更改后用户被重定向到选定的名称范围。我很难直接从下拉控件中获取选定的名称范围。我只得到dronwdown控件的列表值。我做了一个变通的想法,并从主命名范围中选择了适当的单元格,但是我想知道应该有一种方法可以直接获得所选项目的字符串值。我已经试过了。
**这是有效的:
Sub GotoNames()
Dim rng As Range, T As Range
Set rng = ThisWorkbook.Sheets("Panel").Range("NamedRng")
On Error GoTo errr
Retry:
With ThisWorkbook.Sheets("Result").DropDowns(1)
Set T = rng(.Value)
Application.Goto T.Value2
End With
Exit Sub
errr:
If T.Worksheet.Visible = xlSheetHidden Then
T.Worksheet.Visible = xlSheetVisible
resume Retry
End If
End Sub
但我想:
Sub GotoNames()
'On Error Resume Next
With ThisWorkbook.Sheets("Result").DropDowns(1)
Application.Goto .ControlFormat.List(.ControlFormat.ListIndex) 'OR
Application.Goto .ListFillRange(.value)
End With
End Sub