[英]VBA Format Cells based on another sheet
I am needing to add a variable range, per row starting in G2 (always) and carrying through the lastrow/lastcol -4 and then subtracting the value in the D column for each row & entering that result in lastcol-3. 我需要为每行添加一个可变范围,从G2开始(始终)并进行lastrow / lastcol -4,然后为每行减去D列中的值,并在lastcol-3中输入结果。 I've pieced this code together from other codes, and never used function.Sum, so I may be way off.
我已经将此代码与其他代码拼凑在一起,并且从未使用过function.Sum,所以我可能会觉得很遥远。 Here is what I currently have for my code:
这是我目前的代码内容:
lastcol
is a number not a letter and Range, when using strings, expects letters. lastcol
是一个数字,而不是字母,使用字符串时,Range需要字母。
Change to Cells(): 更改为Cells():
sht.Cells(i,lastcol-3).Value = Application.WorksheetFunction.Sum(sht.Range(sht.Cells(i,7),sht.Cells(i,lastcol-4)))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.