trim

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
 
D

Dave Peterson

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), "")
 
R

RobcPettit

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
 
D

Dave Peterson

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
 

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

Similar Threads

split 7
trim not working 2
How to compress interstitial spaces? 6
Split data Macro 2
trim, chr(10) 24
Range issue 3
Type Mismatch 0
Removing spaces is driving me nuts 8

Top