I'm writing a piece of code to split large cells onto new rows, while copying the rest of the cells on that row to the new row, and part of this exercise involves finding any pipe characters and starting a new row with the rest of the cells contents from the pipe. I have almost everything working, but for some reason certain pipes aren't counted and don't start a new line.
The below code is the snippet that does the comparison. For each cell I am checking every character to see if it is a pipe or not
For i = 1 To length
If Mid(subString, i, 1) = "|" Then
'Insert new row
.Cells(rowNo, 1).Offset(1, 0).EntireRow.Insert
'Copy the other cells into this new row
.Cells(rowNo, 1).Offset(1, 0).Value = .Cells(rowNo, 1).Value
.Cells(rowNo, 2).Offset(1, 0).Value = .Cells(rowNo, 2).Value
'increment sequence
.Cells(rowNo, 4).Offset(1, 0).Value = .Cells(rowNo, 4).Value + 1
'Display text for new row from character | onwards
.Cells(rowNo, 3).Offset(1, 0).Value = Mid(subString, i, Len(subString))
'Display text from character position 1 to |
.Cells(rowNo, 3).Value = Mid(subString, 1, i)
subString = .Cells(rowNo, 3).Offset(1, 0).Value
'Increment Row No
rowNo = rowNo + 1
End If
Next i
An example of where this is required is below. My code is starting a new row before Reference, but not before NFPA and I can't work out why
gineer). ||Reference Standards: |NFPA
Any help is appreciated.
Thanks