Spajeoly
Apr 12th, 2006, 04:15 PM
Ok, so i have written a function in VBA to loop through an entire sheet and remove all Chr(10) & 13, separately because yes, sometimes it does happen ( I hate it too).
So, I need to remove them because this piece of software I work with cannot have either of them since it reads CSV's based on the Linux format (Separated by Chr(10) instead of 13 & 10, CrLf).
Now, the thing is, when I run this code it removes them all with no problem. But, it also seems to remove a good 40% of the text. Cuts it off at the end for some reason.
I think I may be using the wrong cell function to do it, but cannot yet be sure as my 1200 page book has no information regarding the difference.
Check out my code below and let me know what you think.
If InStr(1, Range("$" & CellLoc & "$" & i).Text, Chr(10)) Then
SpcReport = SpcReport & CellLoc & i & " contained at least one Line Feed" & Chr(10)
Range("$" & CellLoc & "$" & i).FormulaR1C1 = Replace(Range("$" & CellLoc & "$" & i).Text, Chr(10), "")
End If
If InStr(1, Range("$" & CellLoc & "$" & i).Text, Chr(13)) Then
SpcReport = SpcReport & CellLoc & i & " contained at least one Carriage Return" & Chr(10)
Range("$" & CellLoc & "$" & i).FormulaR1C1 = Replace(Range("$" & CellLoc & "$" & i).Text, Chr(13), "")
End If
Now, Range("$" & CellLoc & "$" & i) gets the current cell being checked. This works super-duper....
But, any attempts to fix the fact that it removes most of the hud at the end of the cell's text have failed.
I wrote an app in VB6 that will open the file and remove it that way but the one I need to distribute at work is the VBA module (Stupid management rules).
So, anyone who can offer advice on why it's slaughtering the text will be very appreciated.
Thanks.
So, I need to remove them because this piece of software I work with cannot have either of them since it reads CSV's based on the Linux format (Separated by Chr(10) instead of 13 & 10, CrLf).
Now, the thing is, when I run this code it removes them all with no problem. But, it also seems to remove a good 40% of the text. Cuts it off at the end for some reason.
I think I may be using the wrong cell function to do it, but cannot yet be sure as my 1200 page book has no information regarding the difference.
Check out my code below and let me know what you think.
If InStr(1, Range("$" & CellLoc & "$" & i).Text, Chr(10)) Then
SpcReport = SpcReport & CellLoc & i & " contained at least one Line Feed" & Chr(10)
Range("$" & CellLoc & "$" & i).FormulaR1C1 = Replace(Range("$" & CellLoc & "$" & i).Text, Chr(10), "")
End If
If InStr(1, Range("$" & CellLoc & "$" & i).Text, Chr(13)) Then
SpcReport = SpcReport & CellLoc & i & " contained at least one Carriage Return" & Chr(10)
Range("$" & CellLoc & "$" & i).FormulaR1C1 = Replace(Range("$" & CellLoc & "$" & i).Text, Chr(13), "")
End If
Now, Range("$" & CellLoc & "$" & i) gets the current cell being checked. This works super-duper....
But, any attempts to fix the fact that it removes most of the hud at the end of the cell's text have failed.
I wrote an app in VB6 that will open the file and remove it that way but the one I need to distribute at work is the VBA module (Stupid management rules).
So, anyone who can offer advice on why it's slaughtering the text will be very appreciated.
Thanks.