Advertisement
YasserKhalil2019

T4240_Split Text By Delimiter Into Two Columns

Oct 29th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. https://excel-egy.com/forum/t4240
  2. ---------------------------------
  3.  
  4. Sub Split_Text_By_Delimiter_Into_Two_Columns()
  5. Dim a, x, i As Long
  6.  
  7. a = Range("E2:F" & Cells(Rows.Count, "E").End(xlUp).Row).Value
  8.  
  9. For i = LBound(a) To UBound(a)
  10. If InStr(a(i, 1), "-") Then
  11. x = Split(a(i, 1), "-")
  12.  
  13. a(i, 1) = Trim(x(0))
  14. a(i, 2) = Trim(x(1))
  15. End If
  16. Next i
  17.  
  18. Range("E2").Resize(UBound(a, 1), UBound(a, 2)).Value = a
  19. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement