【问题标题】:Force VBA to display currently-selected cells when prompting user to select a range with Inputbox in Excel当提示用户在 Excel 中使用输入框选择范围时,强制 VBA 显示当前选定的单元格
【发布时间】:2020-04-03 18:20:38
【问题描述】:

我知道我可以使用 Inputbox 来提示用户选择一个范围

Set rng = Application.InputBox( _
  Title:="Number Format Rule From Cell", _
  Prompt:="Select a cell to pull in your number format rule", _
  Type:=8)

但是当这段代码执行时,输入框最初是空的

我怎样才能让这个框显示当前选择的单元格?

【问题讨论】:

    标签: excel vba inputbox


    【解决方案1】:

    我们可以像这样使用 Inputbox 方法的 Default 属性:

    Set RangeDest = Application.InputBox("Select range to paste onto ", "Obtain Range Object", Selection.Address, Type:=8)
    

    【讨论】:

    • 匹配 OP 的风格:'Default:=Selection.Address'。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-17
    • 1970-01-01
    • 1970-01-01
    • 2021-08-24
    • 1970-01-01
    相关资源
    最近更新 更多