在Excel中提示用户使用Inputbox选择区域时,强制VBA显示当前选定的单元格
我知道我可以使用Inputbox提示用户选择一个范围在Excel中提示用户使用Inputbox选择区域时,强制VBA显示当前选定的单元格,excel,vba,inputbox,Excel,Vba,Inputbox,我知道我可以使用Inputbox提示用户选择一个范围 Set rng = Application.InputBox( _ Title:="Number Format Rule From Cell", _ Prompt:="Select a cell to pull in your number format rule", _ Type:=8) 但是,当执行此代码时,inputbox最初将为空 如何使该框显示当前选定的单元格?我们可以使用Inputbox方法的默认属性,如下所示:
Set rng = Application.InputBox( _
Title:="Number Format Rule From Cell", _
Prompt:="Select a cell to pull in your number format rule", _
Type:=8)
但是,当执行此代码时,inputbox最初将为空
如何使该框显示当前选定的单元格?我们可以使用Inputbox方法的默认属性,如下所示:
Set RangeDest = Application.InputBox("Select range to paste onto ", "Obtain Range Object", Selection.Address, Type:=8)
要匹配OP的样式:“默认值:=Selection.Address”。