Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cleaning up text values

Status
Not open for further replies.

clifftech

ISP
Nov 9, 2001
111
US
I need to develop a macro that will look at the text string value for each row (about 50 rows) in column A and trim 1 or more spaces from the end of the text string. Spaces in the middle of the text string are OK. The spaces at the end of the string need to be eliminated so that the strings can be matched in other functions I am using.

Thanks for the help.



 
this is a pretty basic thing to try - so I recommend giving it a bash yourself. The logic will be

While RightStr(cell, 1) = ' ' do
cell = LeftStr(1, Length(cell) - 1)
 
No need - just use the rTrim function in VBA

for each c in selection
c.value = rtrim(c.value)
next

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top