要查找空单元格并将求和结果保存在该单元格中 [英] To find an empty cell and save the summation result in that cell

查看:64
本文介绍了要查找空单元格并将求和结果保存在该单元格中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想要总结C列并使用VB脚本将结果放在C列的空单元格中。如果我使用下面的代码,那么我可以这样做:


设置oRange = oSheet.Range(" C2:C6")

oSheet.Range(" ; C7")= oExcel.WorksheetFunction.Sum(oRange)









































Header1



Header2



Header3



存档




5




94848629



存档2




10




195704



花费并保存




3




1230653



工作区




0




2



Workspace1




677




247328861







但我需要注意以下我无法达到的条件:


1.行可能是未知的数字。因此动态需要查找列C中的最后一个空单元格然后将列c中的非空单元格(不包括标题)相加并将结果保存在空单元格中。


2.如果有任何"0" ;列D("标题2")中的值然后需要删除该行。




Crynet

解决方案

您尝试了什么?


请参阅以下内容:
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?论坛= exceldev


在此发布如何编程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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆