2009-08-18 8 views
1

Excelでは改行文字(alt + Enter)が含まれていると、セルを2つ以上のセルに自動的に分割できます。どのようにすれば、セルをその行の下の新しいセルに分割するのでしょうか?改行文字が含まれているとセルを破る

+0

私は関係なく、助けることができるが、Excelを知っている人々のためではないだろう、それは場合には役立つかもしれませんそのインターフェイスとのインターフェイス方法を指定します。 COM? –

答えて

1
Sub MakeTwoCellsForCellHavingLF() 
Dim currentCellValue As String, LFFoundAt As Integer 

currentCellValue = ActiveCell.Value 
LFFoundAt = InStr(1, currentCellValue, vbLf) 

If LFFoundAt <> 0 Then 
    ActiveCell.Value = Left(currentCellValue, LFFoundAt - 1) 
    ActiveCell.Offset(1).Value = Mid(currentCellValue, LFFoundAt + 1) 
End If 
End Sub 
0

データがA1であるとします。

A2が含まれている(言い訳とCスタイルのコメントを削除してください。)必要があります。

=FIND(CHAR(10),A1) // Location of CHAR(10), your newline. 

ASCII 10は改行を意味します。非表示行2

A3が含まれている必要があります

=IF(
    NOT(ISERR(A2)), // Make sure there is a newline 
    LEFT(A1, A2-1), // Everything up to the newline 
    A1    // If there's no newline, original string 
    ) 

A4が含まれている必要があります

=IF(
    NOT(ISERR(A2)),  // Make sure there is a newline 
    RIGHT(A1, LEN(A1)-A2), // Everything after the newline 
    ""      // If there's no newline, nothing 
    ) 
関連する問題