Tuesday, 22 June 2021

Excel VBA: splitting cell values into rows

 Delimit cell values into rows. 




Public Sub delimitcell()

    Set targetRange = Range("A1")
    targetDelimiter = ";"
    Set newRange = targetRange.Offset(1, 0)
    
    For i = 0 To UBound(Split(targetRange, targetDelimiter))
        Set newRange = newRange.Offset(1, 0)
        newRange.Value = Split(targetRange, targetDelimiter)(i)
    Next
End Sub

No comments:

Post a Comment