繁体   English   中英

如何将计算值复制到工作表上的选定单元格中?

[英]How to copy calculated value into selected cell on a worksheet?

我当前的计算,将值返回到 msgbox。

我想要一个进一步的 msgbox 询问“你想粘贴值吗”,然后能够选择一个单元格来粘贴值。

我不知道如何保留计算结果以便能够粘贴它。

Sub CalcmsgboxAcre()
    On Error Resume Next
    Dim num As Double
    num = Application.InputBox(prompt:="Please Enter The Number Of Hectares You Would Like To Calculate Into Acres ", Type:=1)
    MsgBox Format(num * 2.471054, "#,##0.00") & " Is the Number Of Acre's."
End Sub

你不需要保存结果,在显示结果后你只需要询问用户是否希望通过这样做来保存它

Save = MsgBox("Do you want to paste the result in a cell?", vbYesNo)

然后,如果答案是肯定的,您需要询问单元格并将结果粘贴在那里

If Save = vbYes Then
    cell = Application.InputBox("In which cell")
    Range(cell).Value = num * 2.471054
End If

希望这会有所帮助,布鲁诺

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM