删除电子表格中<条件>的行当<条件>栏为未知条件>条件>
我需要在电子表格中找到“逾期”和“到期”一词,但它们出现的列将是可变的,记录数(行)也是可变的。我需要删除数据中没有这些值的所有行,然后在删除其他行后汇总工作表上留下的数据。有什么线索吗?
I need to find the word "Overdue" and "Due" in a spreadsheet, but the column they appear in will be variable, as will the number of records (rows). I need to delete all rows that do NOT have these values in the data, then total up the data left on the sheet after the others have been deleted. Any clues?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你可以尝试这样的事情。
将其放入宏中运行
You can try something like this.
Put this into a macro to run
您也可以尝试使用 ADO。
You could also try something with ADO.
Excel 应该能够将除错误之外的任何值强制转换为字符串。因此,如果您的公式返回错误,则可能会导致类型不匹配。这是使用 Find 方法的另一种方法,可以避免该问题。查找可能比循环遍历列慢,但如果您没有大量数据,您将不会注意到它。
注意:此代码会删除数据,因此请在您的真实数据副本上使用它,直到您知道它适合您为止。
Excel should be able to coerce any value into a string except an error. So if you have formulas that return errors, that may be causing the type mismatch. Here's another way using the Find method that would avoid that problem. Find can be slower that looping through the columns, but if you don't have a ton of data, you won't notice it.
Note: This code deletes data so please use it on a copy of your real data until you know that it works for you.