简体   繁体   English

excel vba 如果单元格包含GREP搜索,则删除整行

[英]excel vba Delete entire row if cell contains the GREP search

I have a single column of text in Excel that is to be used for translating into foreign languages.我在 Excel 中有一列文本用于翻译成外语。 The text is automatically generated from an InDesign File.文本是从 InDesign 文件自动生成的。 I would like to clean it up for the translator by removing rows that simply contain a number ("20", 34.5" etc), or if they contain a measurement "5mm", "3.5 µm", etc. I've found many posts (see link below) on how to remove a row with specific string, but none that use search strings, such as those I typically use with GREP searches: "\\d+" and "\\d.\\d µm" How would I do this? I am on Mac iOS if that helps.我想通过删除仅包含数字(“20”、34.5 等)或包含“5mm”、“3.5 µm”等测量值的行来为翻译器清理它。我发现了很多帖子(见下面的链接)关于如何删除具有特定字符串的行,但没有使用搜索字符串,例如我通常用于 GREP 搜索的那些:“\\d+”和“\\d.\\d µm”我该怎么做这个吗?如果有帮助的话,我在 Mac iOS 上。

Note that I would need to delete the row if the cell only contains a number or a measurement, not if the number is contained within a phrase, sentence, or paragraph, etc.请注意,如果单元格包含数字或度量值,而不是该数字包含在短语、句子或段落等中,我将需要删除该行。

https://stackoverflow.com/a/30569969 https://stackoverflow.com/a/30569969

It may not be what you are looking for, but how about just sorting the column and remove the rows starting with numbers?它可能不是您要查找的内容,但是如何对列进行排序并删除以数字开头的行? It is a manual approach but from what I understand this translation process only happens from time to time.这是一种手动方法,但据我所知,这个翻译过程只是不时发生。 Am I right?我对吗?

I see two possible issues in your question:我在您的问题中看到两个可能的问题:

  • How to work with regular expressions in Excel?如何在 Excel 中使用正则表达式?
  • How to delete rows in a loop?如何删除循环中的行?

Let me start with the second question: when you want to create a for-loop in order to remove items from a list, you MUST start at the end and go back to the beginning (it's a beginner's trick, but a lot of people trip over it.让我从第二个问题开始:当您想创建一个 for 循环以从列表中删除项目时,您必须从最后开始并返回到开始(这是一个初学者的技巧,但很多人绊倒超过它。
About the first question: this is a very useful post about this subject, it's too large to even give a summary here.关于第一个问题: 是一篇关于这个主题的非常有用的帖子,它太大了,甚至无法在这里做一个总结。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM