2014-10-28 37 views
-2

嗨計算器社區,文本兩個單元

你將如何實現一個宏,會做以下

A1 "Textcontent 1Information" B1 
A2 "Textcontent 2Information" B2  
A3 "Textcontent 3Information" B2 

到 - >

A1 "Textcontent" B1 "1Information" 
A2 "Textcontent" B2 "2Information" 
A3 "Textcontent" B3 "3Information" 

在口頭上: 到達第一個白/空格時從列中分割文本。 (不管有多少個以下空格) Keeo只有這個單元格的第一部分。 複製第二部分對細胞向右

問候

+1

您可以使用'Left'和'Mid'功能做到這一點。 – 2014-10-28 17:49:58

回答

1

無需VBA。在B1單元格:

=LEFT(A1,FIND(" ",A1,1)) 

在單元格B2:

=TRIM(RIGHT(A1,LEN(A1)-LEN(B1))) 

拖動公式向下至於你所需要的。

enter image description here

0

選擇要處理和運行細胞:

Sub ParseText() 
    Dim r As Range, t As String, i As Long 
    For Each r In Selection 
     t = r.Text 
     i = InStr(1, t, " ") 
     If i > 0 Then 
      r.Value = Mid(t, 1, i - 1) 
      r.Offset(0, 1).Value = Mid(t, i + 1) 
     End If 
    Next r 
End Sub