Excelで複数行の値を統合するVBAマクロ
Excelで、改行のあるテキストを貼り付けた時、PPTなどからコピペした時、複数行に値が分かれてしまって困ることはありませんか。
F2を押して数式バーに貼り付ければ手順的には良いのですが、数が多いとイラッとしますよね。
以下は、7行のセルを1つ目のセルに統合するサンプルです。
Sub IntegCell()
Dim FromCell As String
Dim ToRange As Range
FromCell = ActiveCell.Text
' 2行目から7行目を選択し、1行目に統合 行数を調整したい場合はここを変更
For Each ToRange In ActiveCell.Range("A2:A7")
If ToRange.Text <> "" Then
FromCell = FromCell & vbLf & ToRange.Text
ToRange.Clear
End If
Next ToRange
ActiveCell.Range("A1").Value = FromCell
End Sub
Author And Source
この問題について(Excelで複数行の値を統合するVBAマクロ), 我々は、より多くの情報をここで見つけました https://qiita.com/hone/items/8a456e2e467b36167624著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .