[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Excell 2002 VBA "Trim" commands don't work to remove trailing blanks.

Posted on 2009-02-13
5
Medium Priority
?
363 Views
Last Modified: 2012-05-06
I want my macro to remove trailing blanks from lists of names.  When I type RTrim(A) or Trim(A) as soon as I go to the next line of code the variable separates from the command, i.e., RTrim (A) and doesn't work.  What is an alternate code to remove the last character of a string, in this case a blank?
Thanks
0
Comment
Question by:RogerKMiller
  • 2
  • 2
5 Comments
 
LVL 22

Expert Comment

by:spattewar
ID: 23633204
Hello RogerKMiller,

have you assigned it to a variable?
for e.g.

varA = RTRIM(A)

--varA should then contain the trimmed string which can be used further.

Regards,

spattewar
0
 
LVL 50

Expert Comment

by:Dave Brett
ID: 23633224
I'm not sure why you can't use your varaible down the code  ???
YourVar = Left$(YourVar, Len(YourVar) - 1)

Open in new window

0
 

Author Comment

by:RogerKMiller
ID: 23633493
FOR SOME REASON THAT DIDN'T WORK.
For X = 1 To 4
varA = RTrim(Cells(X, 1))
varB = RTrim(Cells(X, 2))
Next X
0
 
LVL 50

Accepted Solution

by:
Dave Brett earned 1000 total points
ID: 23633632
If you loop without using varA  and varB then they are lost  ....  your code above effectively is
varA = RTrim(Cells(4, 1))
varB = RTrim(Cells(4, 2))
 
suggest you need a pathway using these strings

FOR SOME REASON THAT DIDN'T WORK.
For X = 1 To 4
varA = RTrim(Cells(X, 1))
varB = RTrim(Cells(X, 2))
'do something with variables
Next X

Open in new window

0
 

Author Closing Comment

by:RogerKMiller
ID: 31546595
Thanks for your accuracy and speedy availability.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I came across an unsolved Outlook issue and here is my solution.
Currently, there is an issue with being able to copy values from an external application to a dropdown list in Project Web Access (PWA).  The standard copy and paste methods don't seem to work properly. Here is a way to accomplish this task to s…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question