KEMBAR78
Cell To Row Macro | PDF | Teaching Methods & Materials
0% found this document useful (0 votes)
12 views1 page

Cell To Row Macro

Uploaded by

ErAjayRPal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

Cell To Row Macro

Uploaded by

ErAjayRPal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Sub cell_to_row()

Dim cell As Range


Set cell = Application.InputBox("Select a cell with data to split into rows",
Type:=8)

If cell Is Nothing Then Exit Sub

Dim cellContent As String


Dim splitContent As Variant
Dim i As Integer
Dim startRow As Long
Dim startCol As Long

' Get the content of the cell


cellContent = cell.Value

' Split the content by line breaks


splitContent = Split(cellContent, Chr(10))

' Get the starting row and column of the cell


startRow = cell.Row
startCol = cell.Column

' Shift existing rows down to make space for new rows
Range(Cells(startRow + 1, startCol), Cells(startRow + UBound(splitContent),
startCol)).Insert Shift:=xlDown

' Populate the cells with the split content


For i = LBound(splitContent) To UBound(splitContent)
Cells(startRow + i, startCol).Value = splitContent(i)
Next i
End Sub

You might also like