What character is that?

kin

Well-known Member
Joined
Jun 26, 2007
Messages
648
Hi

do you know any function that recognises which character is in a particular cell?

thanks
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
yes it is 160

how can i use this

Sub test()
With Range("a1:az1000")
.Value = [if(a1:az1000<>"",trim(a1:az1000),"")]
With .Characters(1, 18).Font
.Name = "Arial"
.FontStyle = "?ioiia"
.Size = 10
.ColorIndex = 1
End With
End With
End Sub


to get rid of 160 in a sheet?
 
Upvote 0
trim removes leading and trailing spaces. look at the CLEAN() function.

Sub Macro1()
With Selection
For Each cell In Selection
cell.Value = WorksheetFunction.Clean(cell.Value)
Next
End With
End Sub

btw, with the above. It will work on whichever cell or range of cells are selected. No need to pre-declare what the range is. So select the range, run the macro and BINGO.
 
Last edited:
Upvote 0
btw, the downside of the above sledgehammer approach is that if the errant characters acted as spaces, you'll find your words run together at those points. In that case, the SUBSTITUTE() function would probably provide a bit more finesse. and if you used Alt-Enter to put in a carriage return in the cell, that will also be removed, causing the two words on either side of it to become one.
 
Last edited:
Upvote 0
Hi nbrcrunch

Did you try the code?

The character 160 is the HTML non-breaking space. Being a space I think it will not be "cleaned".

to get rid of 160 in a sheet?

Kin

Can't you just replace it with an empty string?
 
Upvote 0
Odd indeed.

This is what I did:

- in A1: ="Ab"&CHAR(160)&"cd"
- copy, paste special values to A2

Ran the code:

Code:
Sub RmNBSP()
Dim r As Range
 
For Each r In Range("A1:A2")
    r = WorksheetFunction.Clean(r)
Next r
End Sub

I tried it in excel 2000 and excel 2007 and in both case the code did not delete the nbsp.

Can you tell me what is your version of excel?
 
Upvote 0
but you used all valid alpha characters.

what i did was...

type: This is a test.

Between "a" and "test" I entered a Alt-Enter. When wrap it on, "test" will wrap to the next line. When wrap is off, a box-like character will show between the two words. Either way, the macro will strip it off.

The macro is especially useful when getting dumps from certain databases.
 
Upvote 0

Forum statistics

Threads
1,203,465
Messages
6,055,576
Members
444,799
Latest member
CraigCrowhurst

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