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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
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,590
Messages
6,120,421
Members
448,961
Latest member
nzskater

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