简体   繁体   English

VBA格式的单元格基于另一个工作表

[英]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.

相关问题 基于另一个工作表中的匹配的条件格式单元格 - Conditional format cells based on match in another sheet VBA根据另一个无法工作的单元格来格式化单元格 - VBA to format cells based on another cell not working VBA-根据多个条件从另一张纸复制单元格 - VBA - copy cells from another sheet based on multiple criteria VBA附加-根据条件将单元格从一张纸复制到另一张纸 - VBA Append - copy cells froma sheet to another based to a criteria 使用VBA根据另一个工作表中的值填充单元格 - Populating Cells using VBA based on Values from another sheet 格式化单元格以根据行号引用另一个工作表 - Format cells to reference another sheet based on row number Excel VBA,如何使用一个工作表上的下拉列表中的选择格式(颜色)另一工作表上的一系列单元格 - Excel VBA, How to use the selection in a dropdown list on one sheet format(color) a range of cells on another sheet VBA代码可根据条件复制特定列中的单元格并将其粘贴(值)到另一张工作表中特定列中的单元格 - VBA code to copy cells in specific column and paste (value) it to cells in specific column on another Sheet based on conditions 如何使用XlsxWriter根据另一个工作表中的相应单元格值来格式化一个工作表中的所有单元格? - How to format all cells in one sheet based on corresponding cell values in another sheet using XlsxWriter? Excel VBA用于隐藏一个工作表中的单元格(如果它们匹配另一个工作表中的单元格) - Excel VBA for hiding cells in one sheet if they match cells in another sheet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM