Add line breaks in cell to 1000 rows of data

前端 未结 3 366
囚心锁ツ
囚心锁ツ 2021-01-17 01:45

I am currently using the below code to add a line break to cell data in column C and copy it to column K. I need to apply line breaks to a range of data. I have 1000 rows of

3条回答
  •  臣服心动
    2021-01-17 02:07

    Thanks to all for your answers. I atlas was able to write my first script and got the code to add line break inside the cell.

    Sub AddLineBreak()
    Dim Stem As Variant
    Stem = ThisWorkbook.Worksheets("Sheet1").Range("C2")
    
    Dim i As Integer
    i = 2
    'this will terminate the loop if an empty cell occurs in the middle of data
    Do While Cells(i, "C").Value <> ""
      Cells(i, "K").Value = Cells(i, "C").Value & vbCrLf
      i = i + 1
    Loop
    
    End Sub
    

提交回复
热议问题