#1   Report Post  
Posted to microsoft.public.excel.programming
max max is offline
external usenet poster
 
Posts: 12
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default 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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default 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.
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 253
Default 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.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 691
Default 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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
delete extra space WBTKbeezy Excel Worksheet Functions 8 October 8th 06 01:49 AM
Extra Line Space Leesa Excel Discussion (Misc queries) 1 May 24th 05 09:37 PM
Extra Line Space Leesa Excel Discussion (Misc queries) 1 May 24th 05 09:19 PM
Extra Line Space Leesa Excel Discussion (Misc queries) 0 May 24th 05 08:49 PM
Extra line space JJ Excel Discussion (Misc queries) 1 February 18th 05 11:32 PM


All times are GMT +1. The time now is 10:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"