要查找空单元格并将求和结果保存在该单元格中 [英] To find an empty cell and save the summation result in that cell
问题描述
想要总结C列并使用VB脚本将结果放在C列的空单元格中。如果我使用下面的代码,那么我可以这样做:
设置oRange = oSheet.Range(" C2:C6")
oSheet.Range(" ; C7")= oExcel.WorksheetFunction.Sum(oRange)
Header1 | Header2 | Header3 |
存档 | | |
存档2 | | |
花费并保存 | | |
工作区 | | |
Workspace1 | | |
| | |
但我需要注意以下我无法达到的条件:
1.行可能是未知的数字。因此动态需要查找列C中的最后一个空单元格然后将列c中的非空单元格(不包括标题)相加并将结果保存在空单元格中。
2.如果有任何"0" ;列D("标题2")中的值然后需要删除该行。
Crynet
您尝试了什么?
在此发布如何编程Excel:
https://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev&filter=alllanguages
Want to sum up column C and put the result in the empty cell in column C using VB script. If I use the below code then I can do it:
Set oRange = oSheet.Range("C2:C6")
oSheet.Range("C7") = oExcel.WorksheetFunction.Sum(oRange)
Header1 |
Header2 |
Header3 |
Archive |
5 |
94848629 |
Archive 2 |
10 |
195704 |
Spend and Save |
3 |
1230653 |
Workspace |
0 |
2 |
Workspace1 |
677 |
247328861 |
But I need to take care of the following conditions which I can't achieve:
1. Rows may be of unknown numbers. Thus dynamically need to find the last empty cell in column C and then sum up the nonempty cells (excluding Headers) in column c and save the result in the empty cell.
2. if there is any "0" values in column D ("Header 2") then need to delete that row.
Crynet
What have you tried?
See the following: https://social.technet.microsoft.com/Forums/en-US/3fe96d54-e589-4373-82cf-26b459a88883/moving-rows-from-one-sheet-to-another-another-in-the-same-workbook?forum=exceldev
Post here for how to program Excel: https://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev&filter=alllanguages
这篇关于要查找空单元格并将求和结果保存在该单元格中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!