Guest User

Untitled

a guest
Dec 15th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. Dim StartString As String
  2. Dim DateValue As String
  3. Dim y As Integer
  4.  
  5. Dim LastRow2 As Long
  6. With Sheets("DataSheet")
  7. LastRow2 = .Cells(.Rows.Count, "L").End(xlUp).Row 'find the last row on column L
  8. .Columns(13).Insert Shift:=xlToRight 'add a new column to the right of column L
  9. For i = 1 To LastRow2 'loop through rows
  10. If InStr(1, .Cells(i, "L"), ",") Then
  11. .Cells(i, "M").Value = Split(.Cells(i, "L"), ",")(1) 'split after comma
  12. StartString = .Cells(i, "L").Value
  13. DateValue = ""
  14. For y = 1 To Len(StartString) 'loop to remove unwanted characters
  15. Select Case Asc(Mid(StartString, y, 1))
  16. Case 47 To 57
  17. DateValue = DateValue & Mid(StartString, y, 1)
  18. End Select
  19. Next y
  20. .Cells(i, "M").Value = DateValue 'return the date
  21. .Cells(i, "M").NumberFormat = "dd/mm/yyyy" 'format it correctly
  22. End If
  23. Next i
  24. End With
Add Comment
Please, Sign In to add comment