简体   繁体   English

用最后一行单元格值填充Excel MsgBox

[英]Populate Excel MsgBox with last row cell value

I am trying to yield a message box that a user can copy text from. 我试图产生一个消息框,用户可以从中复制文本。 This message box should contain two last row cell values as follows: 此消息框应包含两个最后一行的单元格值,如下所示:

     -MsgBox-
'First Value: xxxx'
'Second Value: xxxx'

I have the following vba to find the last cell number: 我有以下vba来查找最后一个单元号:

Dim Lastrow As String
Lastrow = sumsht.Cells(Rows.Count, 1).End(xlUp).Row

I am wanting to output the last cell S and T values to a message box that a user can copy text from. 我想将最后一个单元格S和T值输出到一个消息框,用户可以从中复制文本。 The below is not correct, although it gives you an idea of what I am trying to do. 下面的内容是不正确的,尽管它使您了解我正在尝试做的事情。

MsgBox.Range(("S" & Lastrow), ("T" & Lastrow))

EDIT: I should mention that my last 'T' cell contains a formula. 编辑:我应该提到我的最后一个'T'单元格包含一个公式。 I am trying to populate the box with the value the formula yields. 我试图用公式产生的值填充框。

EDIT2: This is different to this question as I want the user to be able to actually select the text from the box itself. EDIT2:这与这个问题不同,因为我希望用户能够实际从框中选择文本。 Also I couldn't decipher how to actually create the input box in my context (sorry, I am a beginner). 我也无法解释如何在我的上下文中实际创建输入框(对不起,我是初学者)。

Try as follow: 尝试如下:

Dim Lastrow As String
Lastrow = sumsht.Cells(Rows.Count, 1).End(xlUp).Row

Call MsgBox("First Value: " & sumsht.Range("S" & Lastrow) & vbNewLine & "Second Value: " & sumsht.Range("T" & Lastrow))

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

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