PDA

View Full Version : Solved: string with asterisk



remy988
03-19-2013, 06:43 PM
hi,

i am getting a string from a text file that is no longer than 20 characters in length. the string may contain asterisks that i want to remove.
so for example, if the string is "***APP**LE**, i want the string to be "APPLE".
i want to avoid writing the string to a cell. is this possible?

thanks
rem

GTO
03-19-2013, 07:03 PM
Hi there,

You don't mention how (code example) you are getting the string(s), but have you tried Replace() ?

Sub exa()
Dim myString As String

myString = "**AP**PLE*"
MsgBox Replace(myString, Chr(42), vbNullString)
End Sub

remy988
03-20-2013, 03:43 AM
mark,
just what i needed.
thanks a lot!
rem

snb
03-20-2013, 06:31 AM
You can also remove those asterisks in the worksheet:


Sub M_snb()
activesheet.cells.replace "~*",""
end Sub