Manipulating Strings in a Macro

G

Greg

I am attempting to remove a character from a cell by using a macro with some
VB coding. The cell contains a "special" character in the first position.
The character appears similar to a "bullet" in a word document. The rest of
the cell contains numeric characters. My questions are 1. How do I determine
if the character is present in the cell and 2. how do I remove it, replacing
it with a space character or triming the character from the Cell/Variable.

If I look at a the spreadsheet I can manually detect and Remove/Replace the
character.

The way I do it is :

=If (CODE(A1)>127, TRIM(REPLACE(A1,1," ")),A1)

In my macro I have the contents of the cell to be reviewed in a variable
labeled CONTENT .

Thank You in advance for your suggestions.

Greg
 
M

Mike H

Hi,

You could mofify this. Note i've used MID to return everyting from the
variable CONTENT starting at position 2

content = Range("A1").Value
If Left(content, 1) = Chr(127) Then
Range("A1").Value = Mid(content, 2)
End If

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top