Trim Function for Other Characters

CPGDeveloper

Board Regular
Joined
Oct 8, 2008
Messages
190
I know the Trim Function will remove leading and trailing blank spaces, but is there any similar function that will remove leading and trailing characters of my choosing? For example, if I want to remove leading or trailing commas, periods, dashes, etc...
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Well, there is the Replace function, but that would replace all instances that it finds, not just the trailing ones.

I would recommend creating your own User Defined Function to do something like what you want.
 
Upvote 0
Did you ever get help on how to do this?
I have the same situation and could really use some help. Thank you
 
Upvote 0
@iamkennyj

Perhaps if you give a few examples together with expected results we may be able to help.

Regards
 
Upvote 0
Did you ever get help on how to do this?
I have the same situation and could really use some help. Thank you
Can you provide some more details and examples of exactly what you are trying to do?
 
Upvote 0
@iamkennyj

Perhaps if you give a few examples together with expected results we may be able to help.

Regards

I have the a text field with 65.49- in it to represent negative $65.49. I want to remove the trailing - and make it a negative number field
 
Upvote 0
Try this:
Code:
IIF(Right([MyValue],1)="-",0-Left([MyValue],Len([MyValue])-1),0+[MyValue])
where "MyValue" is your field name.
 
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,151
Members
452,891
Latest member
JUSTOUTOFMYREACH

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