VBA如何使用Excel的内置范围选择强制用户选择范围?

VBA如何使用Excel的内置范围选择强制用户选择范围?,excel,vba,input,selection,Excel,Vba,Input,Selection,我想实现的是,一旦宏运行,用户就必须手动从工作表中进行选择,而不是键入范围,然后将其设置为范围变量 Excel在很多领域都有这样的功能,比如图表的数据选择设置,但我不知道如何访问它。感谢您的任何帮助 下面的将强制用户选择一个范围: On Error Resume Next Dim rng As Range Do Set rng = Application.InputBox(Prompt:="Select Range", Type:=8) Loop While rng Is Nothi

我想实现的是,一旦宏运行,用户就必须手动从工作表中进行选择,而不是键入范围,然后将其设置为范围变量


Excel在很多领域都有这样的功能,比如图表的数据选择设置,但我不知道如何访问它。感谢您的任何帮助

下面的将强制用户选择一个范围:

On Error Resume Next

Dim rng As Range

Do
    Set rng = Application.InputBox(Prompt:="Select Range", Type:=8)
Loop While rng Is Nothing

If Not rng Is Nothing Then rng.Select

On Error GoTo 0

这正是我想要的。非常感谢你。