Advertisement
Guest User

Untitled

a guest
Sep 11th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.17 KB | None | 0 0
  1. Option Explicit
  2.  
  3. Sub cuttingDates()
  4. Application.ScreenUpdating = False
  5.  
  6. Dim iResult As Long
  7. Dim sParts() As String
  8. Dim textToSplit As String
  9. Dim CountChrInString As String
  10. Dim lastrow As Integer
  11. Dim i As Integer
  12. Dim j As Integer
  13. Dim datePart As String
  14. Dim x As Integer
  15. Dim y As Integer
  16. Dim productName As String
  17. Dim newValue As String
  18. Dim newValueTemp As String
  19.  
  20.  
  21. lastrow = Cells(Rows.Count, 2).End(xlUp).Row
  22. y = 2
  23. For i = 2 To lastrow
  24.  
  25.  
  26.  
  27.     textToSplit = Cells(i, 2)
  28.     sParts = Split(textToSplit, ";")
  29.  
  30.     iResult = UBound(sParts, 1)
  31.  
  32.     If (iResult = -1) Then
  33.     iResult = 0
  34.     End If
  35.  
  36.     CountChrInString = iResult
  37.    
  38.     x = 1
  39.    
  40.     For j = 1 To iResult
  41.        
  42.         datePart = Replace(Mid(Cells(i, 2), x, 9), ";", "")
  43.         productName = Cells(i, 1)
  44. '        newValueTemp = datePart & vbNewLine & productName
  45. '        newValue = newValue & vbNewLine & newValueTemp
  46.         Cells(y, 5) = productName
  47.         Cells(y, 6) = datePart
  48.        
  49.         x = x + 9
  50.         y = y + 1
  51.        
  52.     Next
  53. '    Cells(i, 3) = Replace(newValue, ";", "")
  54. '    newValue = ""
  55. Next
  56.  
  57. Application.ScreenUpdating = True
  58.  
  59. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement