LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
KR KR is offline
external usenet poster
 
Posts: 121
Default VBA Trim - has no effect in workbook- looking for ideas

I'm writing this from a different PC (the target workbook is only accessible
from certain PCs) so I will gladly post the code as a followup, but I
figured I'd start with a request for some basic information/ideas. I've done
a fair bit of Excel VBA coding, and this is such a simple thing to not work
properly....

One end user pastes a text file into a worksheet in our shared workbook.
They just changed the format of that report, so now the contents of some
columns contain lagging spaces (lots of them). So for example, a cell that
used to contain "34A71" might now contain "34A71 "

The VBA code starts by loading cells from that worksheet into an array (so
the array values now include those extra spaces).

Then in one part of my code, I pull the values from one "row" at a time from
the array, and compare them against another array. Once I finished pulling
out my hair trying to figure out why the code wasn't working (thats how I
learned about the extra spaces) I added a trim function to the code that
pulls the values. I put a code breakpoint at my trim statement (right before
it actually), and walked through the lines... and lo and behold, the trim
doesn't seem to be doing anything- my variable value still contains
boatloads of spaces. I also tried Application.Trim and
Application.WorksheetFunction.Trim.

Basically, my code is

MyNewValue = Trim(MyArray(A,B,C))

where MyArray is a 3-dimensional array, and the A,B,C represent the location
in that array that has the value I'm pulling.
When I mouseover over MyNewValue after processing this line, it still shows
a string with many spaces regardless of which trim function I use.

I checked Tools/References to see if anything was listed as missing, but it
all looks ok.

Is there any other reason why Trim wouldn't work in the code? I'm completely
stumped at this point.

Thanks,
Keith



--
The enclosed questions or comments are entirely mine and don't represent the
thoughts, views, or policy of my employer. Any errors or omissions are my
own.


 
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
Excell keeps closing when I try to save a workbook. Any ideas! ctd2010 Excel Discussion (Misc queries) 0 February 8th 10 04:27 AM
change settings in a single workbook that doesn't effect another w Curious Setting up and Configuration of Excel 2 December 1st 06 06:25 PM
What is the reverse effect? Rebecca Excel Discussion (Misc queries) 1 March 14th 06 03:21 PM
VBA Trim and Application.worksheetfunction.Trim Hari Prasadh Excel Programming 3 January 19th 05 02:22 PM
Trim like worksheet Trim Bob Phillips[_5_] Excel Programming 0 August 20th 03 07:10 PM


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

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

About Us

"It's about Microsoft Excel"