Close Window
Free Excel Training!
Learn How to Use Macros in Excel!

Trim Function For Other Characters

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...

- Ask any question about Excel and have it answered in no time.

Similar Excel Tutorials

Lets learn how to put multiple functions and formulas in a single cell in Excel in order to build more complex form ...

This allows you to make sure that there are no hidden spaces at the start or end of the text in a cell and also tha ...

Change or replace text in a cell with other text - you can replace a single character, numbers, letters, etc. This ...

Excel formula to delete the first or last word from a cell. You can copy and paste the formulas below for a quick f ...

Helpful Excel Macros

- This macro will delete all text from selected cells. This will not delete any other characters or numbers from any cell

- This UDF (user defined function) extracts the last word or characters from a cell in Excel. This is done by finding the

- Count words in cells with this user defined function (UDF). This UDF allows you to count the number of words that are w

- This free Excel UDF (user defined function) returns the first word from a cell in Excel. This extracts the first word f

- This free Excel macro filters data to display results that end with certain words, text, or characters. This is a very

Similar Topics


I am looking for a formula to remove special characters and spaces from a cell

I have been using "substitute" but this requires me to know which character I want to remove and this isn't always known

I have tried looking at some macro solutions but became lost quite quickly

Any help would be much appreciated


Hello All, I have a column where cells need to be 50 characters long, it contains addresses, however, since all the addresses do not meat the criteria, I need to add (blank spaces) to reach the 50 characters, any idea on how to approach this?


Fire Street #50 this cell contains 17 characters therefore I need to add the rest by adding blank spaces to reach 50 characters, otherwise the system I am exporting the data will not understand this cell

I am looking for a formula to remove special characters (like ', " & - ) in a sheet.
Thank you.

Hi All,

I am trying to make excel automatically add a leading zero to values which are 5 digits long;

i.e. number input is 15185, then excel automatically changes it to 015185.

If I put a Customer Number Format of 0##### it works, however, a user could put any length of number into these cells, and if the number is less than 5 digits I don't want a leading zero.

Is there any way of writing a small macro to sort this out.

The numbers would be input into range B16:223.

Many thanks,



I have several rows of text data, the first 17 characters of which are in this format (4 letters_-_DD.MM.YYYY

It's then followed by a variable number of characters i.e.


I would be grateful for a formula that will delete all characters to the right of the 17th character (i.e. the '3').

Many thanks!

I have imported a DBF file into Excel and have a column of dates that are missing the leading zero on single didgit months. When I try to us the custom format of mm/dd/yyyy it doesn't work (interestingly, after I select that format if I click on an individual cell it changes to the right format).

Does anyone know a better way to do this?

Thanks in advance!

Hello All

I wonder if you could help with this one, I have a list of data like this (no spaces or other characters)


What I need to do is split each of the characters in to its own cell

if JN551122B was in cell A1 I'd want to return:

B2 C2 D2 E2 F2 G2 H2 I2 J2
J N 5 5 1 1 2 2 B

The nearest I have got is the right function, but it brings over the preceeding characters, and I need each character in its own cell. Hopefully I could copy/paste a formula and change the reference for each cell value, i.e. 1 would return J, 2 = N, 3 = 5, 4 = 5 etc.

Thanks for your help!


I'm a bit of a newbie with Excel, but...

I have several cells with data that contain both letters and numbers (4H, 8V, 4FH, etc.) What I want to do is remove only the text characters from these cells, and add the remaining number values together among a series of cells with this data type.

If your answer involves using a macro or VB, please provide a link on how to use the formula. I've never used a macro or VB.


I need to create a IF statement where it will count the character length and if not 6 then add leading zeros to field to make a fixed 6 character length .. so if field is 489 then the if statment would make it 000489


I have a column with a set of duplicate values. I need to remove the duplicates while leaving the original data and keeping the blanks. The Remove Duplicates function comprises the data and this does not work for me. Help!

Hi folks,

Hoping someone can help me quickly as I'm pulling my hair out and have a deadline getting too close.

Been trailing the net and this board but can't work out how to do a simple variance.

How do I work out the difference between two numbers - including negatives.

If the numbers are all positive, it's fine as it's simply a case of A - B = C which is your difference. However, that doesn't work if B is negative.

I need a formula that would give the following:

First Number / Second Number / Difference
1 / 5 / 4
1 / -5 / -6
-1 / 5 / 6
-1 / -5 / -4
-5 / -1 / 4

Hopefully there's a simple function I've been missing.

Thanks in advance, R

I would like to create a formula that removes a specific character if it appears in a cell. In this case, if the text in the name cell starts with * or #, remove it. Otherwise, keep the contents intact. Examples:


Text in Cell Desired Results
*Bobby Abreu Bobby Abreu
#Erick Aybar Erick Aybar
Jason Bartlett Jason Bartlett

Is there a formula that will get me where I want to be?



i have a cell i have to check if it contains six characters. I have a list of data that i need to narrow down to six characters. I have successfully done that, but some of the cell has 5, 6, or 7 characters. The list contains about 600 cells, but i don't have time to format them individually. I want to create a formula that returns true or false if the cell contains 6 characters and false if it is above or below 6.

Can somebody help me, i'm new to excel!

I often use if statements to return empty cells, for example:


The trailing "" returns an empty cell. The problem is, it is not TRULY empty. If I fill that formula down, I cannot, for example, jump from one "ERROR" cell to the next by hitting Ctrl arrow-down because it seems to think that these empty cells have contents.

Is there a way to designate, in such a formula as above, to return a TRULY empty cell?


I am puzzled by a thin black line (that looks like a border line) on a spreadsheet that I am unable to remove, whatever I do. It starts halfway across column B and stops just at the end of column Z.
It is not a border line.
It is not a page break.
If I delete the rows it appears on it remains visible.
It is not an object floating on top of the spreadsheet.
Any ideas?

I run a small business. I want to start keeping track of inventory using a barcode system.

I know Excel "ok", but I don't know programming.'

I'd like to be able to do something very simple (for now)...

For example...if I had PRODUCT / CODE / INV VALUE

A - CODE A - 5
B - CODE B - 11
C - CODE C - 14

I would want to be able to click a button (or scan a code for) : ADD +1 or REMOVE -1

...then scan the barcode on the product (A) and have it add or remove one, respectively. So, if the row for A is:

A - CODE A - 5

I choose "ADD" (with a button or scan code), then scan the barcode, and the spreadsheet automatically finds the code in the sheet, and changes the corresponding inventory value:

A - CODE A - 6

Does that make sense? How might I go about doing that?


I made a budget with many narrow columns and have turned the data into a table. I will only ever filter the data with the left-hand most column. However, all the other columns are filled each with the grey drop-down filter arrow button, and I can no longer see the headings of these columns and frankly seeing 50 little unused arrow buttons is rather ugly. Is there any way to simply remove the filter drop-down buttons on some columns or even all of them, just leaving a filter button at the heading of the first column? I know I can hide the headings, but then I lose sight of the first filter arrow that I use.

Sorry to ask such a bizarre question, but I appreciate your help.


I have a sheet with a list of names on and I've noticed that when I use ctrl+F to use the find function, even when I know i have entered the correct name it still will not work. I have identifed times when I know the name is there on the sheet, but the find function says "Excel cannot find the data you are searching for"

Im unable to put any pics up as my work pc has java disable so photobucket ect won't work but has anyone else come across this problem and how did you rectify it? A search macro perhaps?

Hey everyone - how would I create an IF statement that looks at the first two text characters of a particular cell?

In Excel there is a difference between cells that are blank (= "") and that are empty. You can make blank cells empty by selecting them and pressing the delete key, but I need a fast way to do this on all blank cells in a large worksheet. The only way I have found is with a VBA macro that loops through every cell, tests for '.Value = "" ' and then uses the '.Clear()' function, but doing this on 30 columns x 10000 rows is far too slow. Any solutions?

(The reason I need to do this is for importing into Access, the database treats empty cells as NULL which is what I want. Blank (but not empty) cells screw the import process up.)

Since there isn't a ISDATE function in excel.

The following can be used to simulate the same, and avoid having to achieve the same with VBA's IsDate function:

1- Format the column (ex A) as text

2- Formula to check for valid dates:

Is there an Excel guru that can help with this - its related to "drop down menus"

I have 2 colombs of data.

AT the bottom of the first, I have created a drop down menu using the "data validation" feature in excel.

At the bottom of the second colomb, I have used an "IF" function that returns a result, which depends on what value is chosen from the drop down menu in colomb 1

The problem I have is that I want the TRUE result from the IF function to be another drop down menu, being the data in colomb 2.

How do you write an IF function where the TRUE result is a drop down menu??
I tried to create a drop down menu of colomb2 elsewhere in the spread sheet, and used that cells location as the TRUE value, but this didn't work either...

ANy suggestions??

So I've got some data, which has the approximate form of a sine function. I want to find all the x-axis intercepts. I tried using the intercept function and swapping around the y values for the x values, but it only returns 1 value (so I'd guess it uses a linear regression to estimate a single line through the axis).

I was thinking of trying a nested if/and statement but I haven't quite figured out how to do it. Basically I want to identify the two values where it switches from positive to negative and also indentify the values where it goes negative to positive, I can then fit a straight line between them to find a better approximation of the intercept (though it might not be necessary). Preferably I'd like it all one function as I'm not doing it in VBA (I might do later though, we'll see).

Can anyone suggest how I'd find these value or the x-intercept. Any help would be greatly appreciated.

Is there a worksheet function that will generate all possible combinations of
a set of given numjbers. For example, 1, 3 and 8 would generate 138, 183,
318, 381, 813, 831 and so on...

I have a large spreadsheet in Excel 2007. I am converting it to a .csv file to import in to another program. I need to delete all commas from all data.

When I try to replace all commas (with nothing or with another character), I get the error message "The formula you typed contains an error."

I have tried various formats (text, general, etc.) and various file types (.xls,.xlsx, .csv) and still get the same error.

Related pages

continuous numbering in excelexcel daycareexcel cannot complete this task with available resources 2010payback period calculation formulaexcel boxplotexcel vlookup nadialog box vbaminus formula exceltimesheet calculator excelvba byref argument type mismatchmacros are disabledexcel iterationsexcel cannot open this task with available resourcesodbc connection failed accesshow to print barcode from excelremove blank from pivot tabledemand forecasting excel templatemonthly expense excelvba wildcardsexcel vba change column widthmicrosoft excel remove passwordhow to insert multiple row in excelnon repeating numbershow to auto subtract in excelwhen to insert a semicolonformula of kwhmegastat excel 2010developer tab in excel 2007how to enable macros in excel 2007 permanentlyexcel inputboxvlookup leftcalculate inflection pointexcel multiple formulasexcel filter list based on cell valueexcel motion chartsss contribution table 2010excel npv function examplelac to million converterexcel employee schedule makervlookup 2 conditionshow to split panes in excellast row vbaexcel formula bar missingisblank in excelfunction keys in excelsendkeys mouse clickcount days between dates excel 2010pivot table in business objectshow to use advanced filter in excel 2010count rows vbamissing microsoft windows common controlsexcel macro password breakertime card conversion chart tenthsnumbers excel converterexcell spellingexcel conditional formatting between sheetsaccess workday functionin excel how to calculate age from date of birthest to ist convertersquare root sign in excelruntime error 2147467259excel 2007 enable macroexcel datedifflakhs to crores converterhow to count the colored cells in excelexcel replace charactersstone to kgs calculatorformula to convert kb to mbdelete empty cellscombine multiple excel files into oneinserting a column in excel