【发布时间】:2021-05-03 20:34:40
【问题描述】:
我有一列遵循这种格式的 Excel 单元格(随机字符串的顺序不是固定的)。不以某个字符串开头的字符串需要删除。
randomstringA text_that_needs_to_be_kept1
text_that_needs_to_be_removed1
randomstringB text_that_needs_to_be_kept2
randomstringA text_that_needs_to_be_kept3
text_that_needs_to_be_removed2
我希望单元格的输出是这样的(必须保留换行符):
text_that_needs_to_be_kept1
text_that_needs_to_be_kept2
text_that_needs_to_be_kept3
不是这个(换行符被删除):
text_that_needs_to_be_kept1
text_that_needs_to_be_kept2
text_that_needs_to_be_kept3
【问题讨论】:
-
那么 - 您在实现此功能时遇到的具体问题是什么?你尝试了什么,发生了什么?一种方法可能是在
vbLf上使用Split()来获取行数组,然后循环遍历数组,将您不想要的行设置为空字符串,然后Join()数组以获取结果。
标签: excel vba excel-formula line-breaks string-matching