私はごちゃごちゃして複雑にするのが好きですが、これは非常に簡単なオールドファッションスタイルで行うことができます.
hit Ctrl H
replace your multiple line break chars (i.e. "1234") with a single wild char "~" or "}" are usually good
use Excel's feature "text to columns" to break the line based on your wild char separator. (ctrl +A, +E)
列を区切るためにスペース " " が 1 つしかない場合は、テキストを列に使用し、[区切り] をオンにして、[その他のセパレーター] の下の [] をクリックし、[完了] をクリックします。そしてもちろん、これを行う前に、列をコピーする必要があります(列Cに貼り付け/特別な値を貼り付けてから、列Bに初期値を保持するためにそれを壊します):)これが役に立てば幸いです。
編集
これは私が書いたコードの一部です(少し急いで)。これは、列選択のユーザー入力と、テキストを分割するために使用される文字列を使用して、上記の例に従います。「テキスト ブレーカー」としてスペースのみを使用する必要がある場合は、2 番目のプロンプトに「 」と入力します。通常、コードを「クリーン」にするのに時間がかかりますが、これは 10 分で生成されたものです。
Sub SplitColumns()
DestinationColumn = InputBox("Please enter the name of the column you on which you want to perform the split", _
"Column Selection", "A", 100, 100)
Dim ReplaceRange As Range: Set ReplaceRange = ActiveSheet.Range(DestinationColumn & ":" & DestinationColumn)
SeparatorString = InputBox("Please enter the string of charatesrs used to define the split", _
"String Definition", "anything goes", 100, 100)
' Please be carefull and check for anythinkg like "~" as it will produce errors if found within the cell text
Dim Response As Integer
Response = MsgBox(prompt:= _
"Are you sure you want to split the text from column [" & DestinationColumn & "] based on [" & SeparatorString & "] ?" & vbNewLine & _
"Once the macro is run, there is no Undo Option available(Ctrl+Z)", _
Buttons:=vbYesNo)
If Response = vbYes Then
ReplaceRange.Replace _
What:=SeparatorString, _
Replacement:="~", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False, _
SearchFormat:=False, _
ReplaceFormat:=False
ReplaceRange.TextToColumns _
Destination:=Range(DestinationColumn & "1"), _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, _
OtherChar:="~", _
FieldInfo:=Array(Array(1, 1), Array(2, 1)), _
TrailingMinusNumbers:=True
End If
End Sub
たぶん、このコードを改良するための別のショットを与えるでしょう (別の機会に)。デバッグが行われないことを願っています。Excel 2007 でテストしました。