简体   繁体   English

将公式应用于列中的最后一个单元格

[英]Apply formula to last cell in column

I know this question has been asked before but this question is slightly different, I want to search a column to get the last cell in that column with data in it (which I can do) but I want to apply a formula to the cell which is four columns over to its right. 我知道之前曾问过这个问题,但是这个问题稍有不同,我想搜索一列以获取该列中包含数据的最后一个单元格(我可以这样做),但是我想将公式应用于该单元格右边有四列。 I know I can introduce a formula to a cell by doing the following: 我知道我可以通过执行以下操作为单元格引入公式:

Dim formul As Variant
formul -"=B25 * H25"

ActiveSheet.Range("E" & Rows.Count).End(xlUp).Offset(, 4).Resize(1).Value = formula

but this is where my problem begins, I want to do something like this below, instead of setting the formula because the multiplication of the cells will always be changing when more information is being added to the sheet. 但这是我的问题开始的地方,我想在下面做类似的事情,而不是设置公式,因为当向表中添加更多信息时,单元格的乘法将始终在变化。

formul -"=ActiveSheet.Range("E" & Rows.Count).End(xlUp).Offset(, 3).Value *      
ActiveSheet.Range("E" & Rows.Count).End(xlUp).Offset(, -3).Value"

ActiveSheet.Range("E" & Rows.Count).End(xlUp).Offset(, 4).Resize(1).Value = formul

I need to do it like the way stated above because if I then change any information on the sheet itself it wil updat automatically. 我需要按照上述方式进行操作,因为如果我随后更改工作表本身上的任何信息,它将自动更新。

您可以使用:

ActiveSheet.Range("E" & Rows.Count).End(xlUp).Offset(, 4).formular1c1 = "=RC2*RC8"

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

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