简体   繁体   English

从单元格引用更改的另一张工作表中获取值

[英]Fetch value from another sheet where the cell reference changes

I wish to grab the value from another sheet where the cell reference will change, it changes because im using the lastrow function to enter a autosum into the last row as the data will always change from day to day.我希望从另一个单元格引用将更改的工作表中获取值,它会更改,因为我使用 lastrow function 将自动和输入到最后一行,因为数据总是每天都在变化。

I'm stuck on how i can reference the cell required from another sheet.我被困在如何从另一张纸上引用所需的单元格。

This is the code which creates the auto sum in my sheet named "A" and i want to display the result of this autosum in another sheet.这是在名为“A”的工作表中创建自动求和的代码,我想在另一张工作表中显示此自动求和的结果。

Dim lastrow1 As Long
lastrow1 = ActiveSheet.Cells(Rows.Count, "J").End(xlUp).Row + 1
ActiveSheet.Cells(lastrow1, "J").Value = "=Sum(J2:J" & lastrow1 - 1 & ")"

You can do this without VBA.您可以在没有 VBA 的情况下执行此操作。 I don't know what your data looks like, so let's say this is your data:我不知道您的数据是什么样的,所以假设这是您的数据:

在此处输入图像描述

My personal preference is to put column sums at the top of the column, that way you can freeze the header and sum rows and have the ability to scroll through the data while still seeing the sums.我个人的偏好是将列总和放在列的顶部,这样您就可以冻结 header 和行总和,并且能够在查看总和的同时滚动数据。 To do that, put the headers in Row 2 and start the data in Row 3. Then Row 1 would be C1=SUM(C3:C1000) .为此,将标题放在第 2 行并在第 3 行开始数据。然后第 1 行将是C1=SUM(C3:C1000) Then you can easily reference C1 in another sheet without VBA.然后,您可以在没有 VBA 的情况下轻松地在另一张表中引用 C1。

Alternatively, you could format your data as a table.或者,您可以将数据格式化为表格。 In the Table Design section of the ribbon, mark "Total Row" to create a row at the bottom that sums up all the data above.在功能区的表设计部分中,标记“总行”以在底部创建一行,汇总上述所有数据。 With this way, you could reference the cell with the sum by calling VLOOKUP like this: VLOOKUP("Total",Table1[#All],3,FALSE)通过这种方式,您可以通过调用 VLOOKUP 来引用带有总和的单元格,如下所示: VLOOKUP("Total",Table1[#All],3,FALSE)

暂无
暂无

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

相关问题 单元格值更改时,将单元格值更改所在的列复制到相同范围的另一张工作表 - When a cell value changes, copy the column from where the cell value changed to another sheet at the same range 如何从单元格值引用另一个工作表上的单元格 - How to reference cell on another sheet from cell value 当“最后一张”每月更改时,如何将“最后一张”中的单元格引用(不是值)添加到汇总表公式中 - How to add the cell reference (not value) from “last sheet” to the summary sheet formula when “last sheet” changes every month 如何引用另一个工作表中的单元格? - How to reference a cell from another sheet? 从另一张表中引用 cell.offset - Reference cell.offset from another sheet 使用另一个工作表中的单元格作为参考 - using a cell from another sheet as reference 使用来自另一个工作表的连接引用更新单元格 - updating a cell with a concatenated reference from another sheet 从工作表获取所有行,然后进入另一工作表,其中每一行包含一个与特定值匹配的单元格 - Get all rows from a sheet, into another sheet, where each row contains a cell matching a certain value VBA从工作表1中的单元格引用中选择另一个工作表 - VBA select another sheet from cell reference in sheet 1 如何引用其中工作表名称被引用为其他工作簿中的值的单元格? - How to reference a cell where sheet name is cited as a value from a different workbook?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM