Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
replace last character in string
How can i replace last character in a string?
-- help a friend help you |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Replace a character by it's place in a string | Excel Programming | |||
Replace font of one character in a string | Excel Programming | |||
How replace a character in a string of characters? | Excel Programming | |||
Replace character in string, not document | Excel Programming | |||
How do I replace * as a character in a string in Excel? | Excel Programming |