![]() |
replace last character in string
How can i replace last character in a string?
-- help a friend help you |
replace last character in string
Maybe this
myString = Range("A1").Value NewEnd = "W" myString = Left(myString, Len(myString) - 1) & NewEnd Range("A1").Value=myString Mike "ernie" wrote: How can i replace last character in a string? -- help a friend help you |
replace last character in string
This is one way...
StrVariable = Left(StrVariable, Len(StrVariable) - 1) & YourNewCharacter -- Rick (MVP - Excel) "ernie" wrote in message ... How can i replace last character in a string? -- help a friend help you |
replace last character in string
To replace last character in string called strTemp with a "G" use this
strTemp = Left(strTemp, Len(strTemp) - 1) & "G" "ernie" wrote: How can i replace last character in a string? -- help a friend help you |
replace last character in string
If your text is in a simple variable, then you can also do it this way...
Mid(StrVariable, Len(StrVariable), 1) = YourNewCharacter This is more efficient than using the concatenation method I posted earlier, but it requires your text to be in a simple variable (not a Range or other text holding object) in order to work. -- Rick (MVP - Excel) "Rick Rothstein" wrote in message ... This is one way... StrVariable = Left(StrVariable, Len(StrVariable) - 1) & YourNewCharacter -- Rick (MVP - Excel) "ernie" wrote in message ... How can i replace last character in a string? -- help a friend help you |
replace last character in string
And just to "have fun" (in other words, do not actually use what
follows<g), here is a method that works as long as your text is in not a Unicode font (that is, it only uses ASCII/ANSI character codes of 32 to 255)... Temp = Split(StrConv(StrVariable, vbUnicode), Chr(0)) Temp(UBound(Temp) - 1) = YourNewCharacter StrVariable = StrConv(Join(Temp, Chr(0)), vbFromUnicode) where you would Dim the Temp variable as either a Variant or a dynamic String array. -- Rick (MVP - Excel) "Rick Rothstein" wrote in message ... If your text is in a simple variable, then you can also do it this way... Mid(StrVariable, Len(StrVariable), 1) = YourNewCharacter This is more efficient than using the concatenation method I posted earlier, but it requires your text to be in a simple variable (not a Range or other text holding object) in order to work. -- Rick (MVP - Excel) "Rick Rothstein" wrote in message ... This is one way... StrVariable = Left(StrVariable, Len(StrVariable) - 1) & YourNewCharacter -- Rick (MVP - Excel) "ernie" wrote in message ... How can i replace last character in a string? -- help a friend help you |
All times are GMT +1. The time now is 02:54 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com