0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Excel VBA/セル内の改行をトル

Last updated at Posted at 2019-09-30

Excel VBA/セル内の改行をトル

これを

歌番号 百人一首 作者
61 いにしへの奈良の都の八重桜
今日九重に匂ひぬるかな
伊勢大輔
62 夜をこめて鳥のそら音ははかるとも
世に逢坂の関はゆるさじ
清少納言

こうしたい(セル内の改行を除去したい)

歌番号 百人一首 作者
61 いにしへの奈良の都の八重桜今日九重に匂ひぬるかな 伊勢大輔
62 夜をこめて鳥のそら音ははかるとも世に逢坂の関はゆるさじ 清少納言

コード

Sub 改行トル()
    Dim 範囲 As Range
    Dim 置換文字 As String
    Set 範囲 = Range("b1", "b" & Cells(Rows.Count, 1).End(xlUp).Row)
    範囲.Select
    For Each 範囲 In Selection
        置換文字 = 範囲.Value
        置換文字 = Replace(置換文字, vbLf, "")
        範囲.Offset(, 1).Value = 置換文字
    Next
End Sub

解説

0
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?