ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   extra space (https://www.excelbanter.com/excel-programming/297916-extra-space.html)

max

extra space
 
I'm running a macro to compare to sets of values, but it's not working because after one imported strings has a space on the end it

Grateful for any ideas to get round this problem.

Leo Heuser[_3_]

extra space
 
MAx

Check out the RTrim-function.

--
Best Regards
Leo Heuser

Followup to newsgroup only please.

"MAx" skrev i en meddelelse
...
I'm running a macro to compare to sets of values, but it's not working

because after one imported strings has a space on the end it.

Grateful for any ideas to get round this problem.




Pete McCOsh

extra space
 
Max,

it kind of depends on where you're getting the data from
and what you're diong with it. However, you can use the
TRIM function to remove any leading or trailing spaces,
either as a worksheet formula, which you can then use as a
basis for your comparison:

=Trim(B1)

Or in your macro to manipulate the cell value:

for X=1 to 10

If Application.WorksheetFunction.Trim(Cells(2,x).valu e)= _
Cells(1,x).Value Then
... your code here...
End If

Next X

Cheers, Pete.

-----Original Message-----
I'm running a macro to compare to sets of values, but

it's not working because after one imported strings has a
space on the end it.

Grateful for any ideas to get round this problem.
.


Jean-Yves[_2_]

extra space
 
Hi Max,

You can use the Trim function to remove leading and trailing blanks (before
and after - not in the middle)
Regards,
Jean-Yves

"MAx" wrote in message
...
I'm running a macro to compare to sets of values, but it's not working

because after one imported strings has a space on the end it.

Grateful for any ideas to get round this problem.




david mcritchie

extra space
 
Hi <insert real name here aka MAx,
Did you really check the code or does it just look like a space.
If you got the data from HTML you almost definitely have
&nbsp; a code(160) nonbreaking space character.
See TRIMALL macro for details
http://www.mvps.org/dmcritchie/excel/join#trimall
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"MAx" wrote m...
I'm running a macro to compare to sets of values, but it's not working because
after one imported strings has a space on the end it.

Grateful for any ideas to get round this problem.





All times are GMT +1. The time now is 03:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com