简体   繁体   English

在工作表的最后一行中用另一个替换单元格值

[英]Replacing a cell value with another in the last row of a sheet

I am trying to replace a value in the first column in the last row of a spreadsheet with another value. 我正在尝试用另一个值替换电子表格最后一行的第一列中的值。 For example I have a workbook with two sheets called Input and Data. 例如,我有一本工作簿,其中有两张纸,分别称为“输入”和“数据”。 I have a value on the input sheet in cell A1. 我在单元格A1的输入表上有一个值。 I would like this value to replace the value located in column A in the last row with a value in the Data sheet. 我希望此值可以用数据表中的值替换位于最后一行的A列中的值。 I know how to locate last row of the worksheet using the code below, but I am not sure how to input a value located in this last row. 我知道如何使用下面的代码定位工作表的最后一行,但是我不确定如何输入位于最后一行的值。 What can I add to this in order to retrieve the value I have in the sheet Input in cell A1, and replace the value in column A in the last row of the Data sheet 我可以添加什么以便检索工作表A1中输入的值,并替换数据表最后一行中列A的值

Dim LR1 As Long
'Selects the last row with values
With Sheets("Data")
    LR1 = .Range("A" & .Rows.Count).End(xlUp).Row
End With

Full solution below: 完整解决方案如下:

Dim LR1 As Long
    With Sheets("Data")
        LR1 = .Range("A" & .Rows.Count).End(xlUp).Row
        .Range("A" & LR1) = Sheets("Input").Range("A1")
    End With

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

相关问题 根据另一张纸上的另一个单元格值返回一行中的最后一个值 - Return last value in a row, based on another cell value on another sheet 如果工作表上的单元格值与另一张表上的单元格值相同,则删除该行 - Delete the row if the cell value on sheet is the same then the cell value on another sheet 根据单元格中的值将行复制到另一张工作表 - Copy row to another sheet based on value in a cell 创建指向另一个 Excel 工作表单元格的链接,并查找最后一个单元格值 - create a link to another excel sheet cell with lookup for last cell value 使用另一个工作表中单元格的位置获取最后一个单元格的值 - Getting the Value of the Last Cell Using the Location of a Cell in Another Sheet 用另一个替换单元格中的值 - Replacing a value in a cell with another 试图在 sheet1 的最后一行的 b 列中查找单元格的值 - Trying to find the value of a cell in column b of the last row in sheet1 根据单元格值将特定数据(不是整行!)复制到另一张表 - Copy Specific data (Not the entire row!) to another sheet based on cell value 如果C的单元格值与工作表名称匹配,如何将行复制到另一工作表 - How to copy row to another sheet if the cell value of C matches the sheetname 将显式列与另一工作表中的单元格值用于行 - Using an explicity Column with a cell value from another sheet for Row
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM