trim

  • Thread starter Thread starter RobcPettit
  • Start date Start date
R

RobcPettit

Hi, I have a string
<cardcounter>4,4,6,3,10,12,6,10,9,7,6,5,7</cardcounter> and Im trying
to seperate the numbers and put them into there own cells. So far Ive
played with:
point2 = Replace(ActiveCell, "<cardcounter>", "")
point2 = Replace(point2, "</cardcounter>", "")
point2 = Replace(point2, " ", "")
point2 = Trim(point2)
split1 = Split(point2, ",")
point1 = Trim(split1(0))
point1 = split1(1)
point1 = split1(2)
point1 = split1(3)
point1 = split1(4)
Overall this works well. One problem Im having is when i get to the
'point1 = Trim(split1(0))' i have " 4". The first number but with a
leading space. Originally I used ' point1 = split1(0)' then I noticed
the space so I changed it to trim. But trim isnt getting rid of the
space. I thought 'point2 = Replace(point2, " ", "")', would have got
rid of the space. But i think thats only internal spaces. Any ideas how
to trim this appreciated.
Regards Robert
 
I'm not sure where the spaces were introduced. I put your string in a cell and
didn't have any problem.

But maybe your post doesn't really show what's in the cell.

If it's not a space character, maybe it's one of those HTML non-breaking spaces.

point2 = Replace(point2, chr(160), "")
 
Thankyou for your reply. Your right, chr(160) cleared it. Does chr(160)
refer to HTML characters/non-breaking spaces. Anyway this solved my
problem. Thankyou for taking the time.
Regards Robert
 
Yep. the NBSP is chr(160).


Thankyou for your reply. Your right, chr(160) cleared it. Does chr(160)
refer to HTML characters/non-breaking spaces. Anyway this solved my
problem. Thankyou for taking the time.
Regards Robert
 
Back
Top