Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10
Default delete "-" in cells

I am trying to rid all the pucuations "(,),-" from a column of phone
numbers. I
have used the replace function with evrything OK except "-". It says it
finds
no entries with a "-". I tried just - and then '- but it never finds it.
What should
I use to find them?

Thanks.....


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,688
Default delete "-" in cells

Hi!

Try this:

Get the ascii character code:

A1 = 123-4567

=CODE(MID(A1,4,1))

The code for a standard hyphen is 45. Use the code number returned by the
formula in EditReplace. For example:

EditReplace
Find what: hold down the ALT key and use the *numeric keypad* and type 045
(use the code number returned by the formula)

Biff

"bob engler" wrote in message
...
I am trying to rid all the pucuations "(,),-" from a column of phone
numbers. I
have used the replace function with evrything OK except "-". It says it
finds
no entries with a "-". I tried just - and then '- but it never finds it.
What should
I use to find them?

Thanks.....




  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 158
Default delete "-" in cells

Try copying just that symbol from one of the phone numbers, and pasting that
into the "Find What" space in the Replace function.

"bob engler" wrote:

I am trying to rid all the pucuations "(,),-" from a column of phone
numbers. I
have used the replace function with evrything OK except "-". It says it
finds
no entries with a "-". I tried just - and then '- but it never finds it.
What should
I use to find them?

Thanks.....



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default delete "-" in cells

Chip Pearson has a very nice addin that will help determine what that
character(s) is:
http://www.cpearson.com/excel/CellView.htm

Since you do see a box, then you can either fix it via a helper cell or a macro:

=substitute(a1,char(13),"")
or
=substitute(a1,char(13)," ")

Replace 13 with the ASCII value you see in Chip's addin.

Or you could use a macro (after using Chip's CellView addin):

Option Explicit
Sub cleanEmUp()

Dim myBadChars As Variant
Dim myGoodChars As Variant
Dim iCtr As Long

myBadChars = Array(Chr(10), Chr(13)) '<--What showed up in CellView?

myGoodChars = Array(" ","") '<--what's the new character, "" for nothing?

If UBound(myGoodChars) < UBound(myBadChars) Then
MsgBox "Design error!"
Exit Sub
End If

For iCtr = LBound(myBadChars) To UBound(myBadChars)
ActiveSheet.Cells.Replace What:=myBadChars(iCtr), _
Replacement:=myGoodChars(iCtr), _
LookAt:=xlPart, SearchOrder:=xlByRows, _
MatchCase:=False
Next iCtr

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

You could get all the characters you find by changing this:

myBadChars = Array("(", ")", "-", Chr(####))
myGoodChars = Array("", "", "", "")

make sure you have the same number of elements.

And change this line:

ActiveSheet.Cells.Replace What:=myBadChars(iCtr), _
to
Selection.Cells.Replace What:=myBadChars(iCtr), _

(Just select the range you want to fix before you run the macro.)

bob engler wrote:

I am trying to rid all the pucuations "(,),-" from a column of phone
numbers. I
have used the replace function with evrything OK except "-". It says it
finds
no entries with a "-". I tried just - and then '- but it never finds it.
What should
I use to find them?

Thanks.....


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete a group of alternate cells poleary53 New Users to Excel 1 March 7th 06 11:05 PM
Code to delete rows and column cells that have formulas in. GarToms Excel Worksheet Functions 1 January 18th 06 01:04 PM
delete cells with formulas Rere New Users to Excel 1 December 28th 05 06:19 PM
Macro to delete data in 'green' cells only Steve Excel Worksheet Functions 7 March 19th 05 01:40 PM
How do I 'catch' a 'delete cells' event Eric Excel Discussion (Misc queries) 2 March 9th 05 07:22 PM


All times are GMT +1. The time now is 06:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"