[英]How do I remove certain text from a cell in Excel?
我在Excel中有一個包含以下內容的單元格:
@dickfundy @ThatKevinSmith @aliciamalone @MovieMantz @dickfundy不,只是陌生人事物第2季或Ready Player https:xxxxxxxxxxx
我想刪除用戶名(所有以“ @”開頭的內容),我也想刪除網絡鏈接(“ https:xxxxxxxxxxx”),最后在單元格中使用以下名稱:
不只是《陌生人事物》第2季或准備就緒的玩家
我還有60,000個包含相似文本的其他單元格。 我該怎么做呢?
我相信您的Excel版本具有TEXTJOIN
函數。 既然如此,您可以使用此數組公式
=TEXTJOIN(" ",TRUE,IF((LEFT(TRIM(MID(SUBSTITUTE(TRIM(A1)," ",REPT(" ",999)),seq_999,999)))="@")+(LEFT(TRIM(MID(SUBSTITUTE(TRIM(A1)," ",REPT(" ",999)),seq_999,999)),4)="http"),"",TRIM(MID(SUBSTITUTE(TRIM(A1)," ",REPT(" ",999)),seq_999,999))))
其中seq_999
是一個命名公式,
refers to: =IF(ROW(INDEX(Sheet1!$1:$65535,1,1):INDEX(Sheet1!$1:$65535,255,1))=1,1,(ROW(INDEX(Sheet1!$1:$65535,1,1):INDEX(Sheet1!$1:$65535,255,1))-1)*999)
要輸入/確認數組公式 ,請在按Enter的同時按住ctrl + shift 。 如果正確執行此操作,Excel會將括號{...}
放在在公式欄中看到的公式周圍。
作為UDF:
Function FixIt(s As String) As String
s = CleanUp(s, "@")
s = CleanUp(s, "http")
FixIt = Trim(s)
End Function
'remove all text segments beginning with LookFor, up to the next space
' or until the end of the input string s
Function CleanUp(s As String, LookFor As String) As String
Dim pos As Long, pos2 As Long, rv As String
rv = s
pos = InStr(1, rv, LookFor)
Do While pos > 0
pos2 = InStr(pos + 1, rv, " ")
If pos2 = 0 Then pos2 = Len(rv)
rv = Left(rv, pos - 1) & Right(rv, Len(rv) - pos2)
pos = InStr(1, rv, LookFor)
Loop
CleanUp = rv
End Function
如果您想要強大的東西:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.