vba 将弹出窗口的输入分配给excel中的单元格

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16252816/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 20:51:36  来源:igfitidea点击:

Assign input of pop up window to a cell in excel

excelexcel-vbapopupvba

提问by xyz

I need a pop up imput box that asks for a long date ex Friday, April 24, 2013 then adds the date to cell I2.

我需要一个弹出输入框,要求输入一个长日期,例如 2013 年 4 月 24 日星期五,然后将日期添加到单元格 I2。

I Googled looking for something like this and found

我用谷歌搜索这样的东西,发现

Public Function AskForResult() As String
    Dim strUserResponse As String

    strUserResponse = InputBox("Please Enter a Long Date")

End Function

But I can't figure out how to assign the input to the cell I2.

但我不知道如何将输入分配给单元格 I2。

Thanks

谢谢

采纳答案by David

You could add this line after your InputBox line:

您可以在 InputBox 行之后添加此行:

ActiveSheet.Cells(2, 9).Value = strUserResponse

the 2, 9 is the cell reference for I2 - row 2, column 9.

2, 9 是 I2 的单元格引用 - 第 2 行,第 9 列。