在Excel中select两个单词之间的macros
有人可以帮我在这个excel 。 我需要select我之前定义的两个单词,并将其删除。
例如:
http:/ ertwertw4r!%!+ 53445433333 / cat.jpg有一只狗
我需要从http:
直到.jpg
select文本并删除它或replace为“。 因为我只需要有一个狗的一部分
这个词成功了
Sub Macro () Selection.Find.ClearFormatting With Selection.Find .Text = "http:" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue End With Selection.Find.Execute Selection.Extend Selection.Find.ClearFormatting With Selection.Find .Text = ".jpg" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue End With Selection.Find.Execute End Sub
问候
录制一个用“”replace“http:*。jpg”的macros我得到:
Selection.Replace What:="http:*.jpg", Replacement:="", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False
“http:*。jpg”是指任何以“http:”开头并以“.jpg”结尾的内容。 之前或之后的任何文本都留在原地。
如果你的string总是有.jpg
,那么你可以使用一个常规的Excel公式(无VBA):
=RIGHT(A1, LEN(A1)-(FIND(".jpg",A1)+3) )