Thread: extra space
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Pete McCOsh Pete McCOsh is offline
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.
.