remove trailing returns from a string

reedssr

New Member
Joined
Feb 11, 2005
Messages
27
Rtrim does not work to do this and i have other returns in the text i do not want to remove. I tried using replace and specifying the start location, but it cut the entire string and only ended up being the length from where I specified to start the replace from. I haven't done a ton of string manipulation in VBA, i know how i could do this in several other languages, but does anyone know how to do it in vba?
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
yes, it only trims white space, white space being spaces, not carriage returns or which charachter chr(10) is. I was thinking of using instr then mid to trim off the railing return chars
 
Upvote 0
FWIW, my approach would be similar, but not quite the same: search(char(10),A1) and left(a1,....

You don't have to use VBA for this; I refrain from VBA when an on-sheet solution is available.

Nonetheless, McRitchie's work is fine, if you do go that way.
 
Upvote 0
i got it to work by using instr and mid to check just the first or last charachter and if it was chr(10) then do a mid on it, thanks for the other suggestions
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,858
Members
449,052
Latest member
Fuddy_Duddy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top