[help] VBA Replace in Text won't finish at the end of text

maulana

New Member
Joined
Sep 16, 2009
Messages
20
Hi,
i want try to change some character in one cell with replace functions in VBA to another cell.

every rows seem ok but at 13th row.
i miss full code. not fully code can't be replace and severed at the end of code.
Code:
Dim p As String
 
 Set a = ActiveWorkbook.Sheets("temp")
 i = 1
 
 While a.Cells(i, 5).Value <> ""
     p = a.Cells(i, 5).Value
     
     p = Replace(p, "+", "|+|", vbTextCompare)
     p = Replace(p, "-", "|-", vbTextCompare)
     p = Replace(p, "(", "|(|", vbTextCompare)
     p = Replace(p, ")", "|)|", vbTextCompare)
     p = Replace(p, "!", "!|", vbTextCompare)
     p = Replace(p, ";", "|;|", vbTextCompare)
     p = Replace(p, "&", "|&|", vbTextCompare)
     p = Replace(p, "||", "|", vbTextCompare)
     a.Cells(i, 6).Value = "'" & p
     i = i + 1
 Wend
 
 
 End Sub
here is my workbooks.
http://www.filehosting.org/<wbr>file/details/160732/max_text.<wbr>xls
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
The maximum number of characters in a cell is 32767. Your 13th row result is longer than that so it truncates. To put the remaining characters in the next column, replace:
Code:
     a.Cells(i, 6).Value = "'" & p
with:
Code:
        a.Cells(i, 6).Value = "'" & Left(p, 32766)
        If Len(p) > 32766 Then
            a.Cells(i, 7).Value = "'" & Mid(p, 32767, Len(p))
        End If
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,767
Members
449,049
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top