1
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

posted at

updated at

Organization

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

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

解説

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
1
Help us understand the problem. What are the problem?