我正在做一些VB编程,但找不到解决我问题的方法。由于我是编程的新手,所以我想寻求帮助。
我有多个Excel文件,它们在单元格中包含某个字符串,在此字符串下方,有一个我想在最后一个单元格中总结的不同数字。
问题是,我要查找的带有字符串的列在带约束的工作表中是变量。
我想知道如何在某一行中搜索字符串,以及何时找到该字符串,我想对该列中的所有数字求和。
谢谢您的帮助。
所以,如果您看示例,我想找到包含字符串“ aaa | b”的单元格,然后将该列中最后一个单元格下面的最后一个单元格中的数字求和。
由于此列在多个Excel文件中的不同位置,所以我必须先找到它并进行所有数学运算。
下面是您所要求的简要概述。大纲不完整,但确实说明您要求的是简单的解决方案。还包含许多问题,例如如果 ....?应该在请求本身中解决。
'folder chooser
'dir on xls in this folder
'open xls
'find row with "HELPER" in column A (or is it always r=3? what if it is not?)
'loop find column(s) with keyword aaa|b (can there be multiple columns? What if none found?)
'find last row (down this column? or last row across all columns?)
'insert in cell below last value a macro =sum(firstcell, lastcell)
'loop to other columns
'save xls
'dir to next xls in this folder
'loop to open xls