Excel VBA - 删除字符串内容最多*字* [英] Excel VBA - delete string content up to *word*

查看:294
本文介绍了Excel VBA - 删除字符串内容最多*字*的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试删除字符串内容,直到字符串中包含的某个字。例如

I'm trying to delete string content up to a certain word contained within the string. For example

"Emily has wild flowers. They are red and blue."

我想使用VBA替换为

"They are red and blue."

即。删除所有内容,直到单词他们。我不知道字符串内容和其中包含的字符数。

i.e. remove all the content up to the word "They". I don't know the string content and the number of characters contained in it.

我不知道该怎么做,我非常感谢您的帮助!

I'm not sure how to do this and I'd really appreciate your help!

推荐答案

你去:

Dim s As String
s = "Emily has wild flowers. They are red and blue."

Dim indexOfThey As Integer

indexOfThey = InStr(1, s, "They")


Dim finalString As String
finalString = Right(s, Len(s) - indexOfThey + 1)

这篇关于Excel VBA - 删除字符串内容最多*字*的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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