PC Review


Reply
Thread Tools Rate Thread

How can I delete a space/character from a number of fields?

 
 
BABs
Guest
Posts: n/a
 
      17th Feb 2010
I have a column that has hyphenated numbers (XX-XX-XX-XXX-XXXX) and I need to
get rid of the hyphens. They are all in the same format so I think if I
could write code to del the 3rd, 6th, 9th, etc characters from a cell, it
would work. I just can't seem to figure the code out. or is there an easier
way?
Thx.
 
Reply With Quote
 
 
 
 
Rick Rothstein
Guest
Posts: n/a
 
      17th Feb 2010
Why not just select the all the cells and use Excel's Edit/Replace to
replace the hyphens with the empty string (put a hyphen in the "Find what"
field and leave the "Replace with" field empty)?

--
Rick (MVP - Excel)


"BABs" <(E-Mail Removed)> wrote in message
news:135C5D11-000A-4F43-BDB0-(E-Mail Removed)...
>I have a column that has hyphenated numbers (XX-XX-XX-XXX-XXXX) and I need
>to
> get rid of the hyphens. They are all in the same format so I think if I
> could write code to del the 3rd, 6th, 9th, etc characters from a cell, it
> would work. I just can't seem to figure the code out. or is there an
> easier
> way?
> Thx.


 
Reply With Quote
 
Ryan H
Guest
Posts: n/a
 
      17th Feb 2010
There is a very easy way without using code. I will assume you are using
Excel 2007. Just highlight the column with the hyphenated numbers, click the
Find & Select button in the Home tab on the Ribbon, click Replace, in the
Find What field type -, and leave the Replace With field empty, then click
the Replace All button. That should do it for you.

Hope this helps! If so, let me know, click "YES" below.
--
Cheers,
Ryan


"BABs" wrote:

> I have a column that has hyphenated numbers (XX-XX-XX-XXX-XXXX) and I need to
> get rid of the hyphens. They are all in the same format so I think if I
> could write code to del the 3rd, 6th, 9th, etc characters from a cell, it
> would work. I just can't seem to figure the code out. or is there an easier
> way?
> Thx.

 
Reply With Quote
 
Ryan H
Guest
Posts: n/a
 
      17th Feb 2010
If you need code you can use this. Just change the range to fit your
application. Hope this helps! If so, let me know, click "YES" below.

Sub ReplaceHyphens()

Dim MyRange As Range

Set MyRange = Range("A:A")
MyRange.Replace What:="-", Replacement:="", _
LookAt:=xlPart, SearchOrder:=xlByRows, _
MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

End Sub
--
Cheers,
Ryan


"BABs" wrote:

> I have a column that has hyphenated numbers (XX-XX-XX-XXX-XXXX) and I need to
> get rid of the hyphens. They are all in the same format so I think if I
> could write code to del the 3rd, 6th, 9th, etc characters from a cell, it
> would work. I just can't seem to figure the code out. or is there an easier
> way?
> Thx.

 
Reply With Quote
 
Jef Gorbach
Guest
Posts: n/a
 
      17th Feb 2010
or if you're looking for a code snippet -


Cells.Replace What:="-", Replacement:="", LookAt:=xlPart, SearchOrder
_
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False
 
Reply With Quote
 
BABs
Guest
Posts: n/a
 
      17th Feb 2010
This works but changes everything to scientific format or rounds off to the
nearest thousand. Can't figure out how to keep the hundreds, tens and ones.
????



"Ryan H" wrote:

> There is a very easy way without using code. I will assume you are using
> Excel 2007. Just highlight the column with the hyphenated numbers, click the
> Find & Select button in the Home tab on the Ribbon, click Replace, in the
> Find What field type -, and leave the Replace With field empty, then click
> the Replace All button. That should do it for you.
>
> Hope this helps! If so, let me know, click "YES" below.
> --
> Cheers,
> Ryan
>
>
> "BABs" wrote:
>
> > I have a column that has hyphenated numbers (XX-XX-XX-XXX-XXXX) and I need to
> > get rid of the hyphens. They are all in the same format so I think if I
> > could write code to del the 3rd, 6th, 9th, etc characters from a cell, it
> > would work. I just can't seem to figure the code out. or is there an easier
> > way?
> > Thx.

 
Reply With Quote
 
Ryan H
Guest
Posts: n/a
 
      17th Feb 2010
Select your data, then right click the highlighted selection, select Format
Cells, select number, then choose which decimal place you want. Hope this
helps! If so, let me know, click "YES" below.

--
Cheers,
Ryan


"BABs" wrote:

> This works but changes everything to scientific format or rounds off to the
> nearest thousand. Can't figure out how to keep the hundreds, tens and ones.
> ????
>
>
>
> "Ryan H" wrote:
>
> > There is a very easy way without using code. I will assume you are using
> > Excel 2007. Just highlight the column with the hyphenated numbers, click the
> > Find & Select button in the Home tab on the Ribbon, click Replace, in the
> > Find What field type -, and leave the Replace With field empty, then click
> > the Replace All button. That should do it for you.
> >
> > Hope this helps! If so, let me know, click "YES" below.
> > --
> > Cheers,
> > Ryan
> >
> >
> > "BABs" wrote:
> >
> > > I have a column that has hyphenated numbers (XX-XX-XX-XXX-XXXX) and I need to
> > > get rid of the hyphens. They are all in the same format so I think if I
> > > could write code to del the 3rd, 6th, 9th, etc characters from a cell, it
> > > would work. I just can't seem to figure the code out. or is there an easier
> > > way?
> > > Thx.

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      17th Feb 2010
After edit>replace change formatting to Number with no DP.

Your example shows 14 digits..........Excel will handle up to and including
15 digits.


Gord Dibben MS Excel MVP

On Wed, 17 Feb 2010 11:49:02 -0800, BABs <(E-Mail Removed)>
wrote:

>This works but changes everything to scientific format or rounds off to the
>nearest thousand. Can't figure out how to keep the hundreds, tens and ones.
>????
>
>
>
>"Ryan H" wrote:
>
>> There is a very easy way without using code. I will assume you are using
>> Excel 2007. Just highlight the column with the hyphenated numbers, click the
>> Find & Select button in the Home tab on the Ribbon, click Replace, in the
>> Find What field type -, and leave the Replace With field empty, then click
>> the Replace All button. That should do it for you.
>>
>> Hope this helps! If so, let me know, click "YES" below.
>> --
>> Cheers,
>> Ryan
>>
>>
>> "BABs" wrote:
>>
>> > I have a column that has hyphenated numbers (XX-XX-XX-XXX-XXXX) and I need to
>> > get rid of the hyphens. They are all in the same format so I think if I
>> > could write code to del the 3rd, 6th, 9th, etc characters from a cell, it
>> > would work. I just can't seem to figure the code out. or is there an easier
>> > way?
>> > Thx.


 
Reply With Quote
 
BABs
Guest
Posts: n/a
 
      17th Feb 2010
I am not using decimals. It changes 13-30-234-1000-2904 to 133023410002000,
rounding off to the thousands. I need it to keep the 2904 at the end. I've
tried formatting the column as text, numbers with different formats, custom,
etc. but they all seem to round and drop the 904 to 000.
Any ideas?



"Ryan H" wrote:

> Select your data, then right click the highlighted selection, select Format
> Cells, select number, then choose which decimal place you want. Hope this
> helps! If so, let me know, click "YES" below.
>
> --
> Cheers,
> Ryan
>
>
> "BABs" wrote:
>
> > This works but changes everything to scientific format or rounds off to the
> > nearest thousand. Can't figure out how to keep the hundreds, tens and ones.
> > ????
> >
> >
> >
> > "Ryan H" wrote:
> >
> > > There is a very easy way without using code. I will assume you are using
> > > Excel 2007. Just highlight the column with the hyphenated numbers, click the
> > > Find & Select button in the Home tab on the Ribbon, click Replace, in the
> > > Find What field type -, and leave the Replace With field empty, then click
> > > the Replace All button. That should do it for you.
> > >
> > > Hope this helps! If so, let me know, click "YES" below.
> > > --
> > > Cheers,
> > > Ryan
> > >
> > >
> > > "BABs" wrote:
> > >
> > > > I have a column that has hyphenated numbers (XX-XX-XX-XXX-XXXX) and I need to
> > > > get rid of the hyphens. They are all in the same format so I think if I
> > > > could write code to del the 3rd, 6th, 9th, etc characters from a cell, it
> > > > would work. I just can't seem to figure the code out. or is there an easier
> > > > way?
> > > > Thx.

 
Reply With Quote
 
BABs
Guest
Posts: n/a
 
      17th Feb 2010
And therein lies my problem, thank you. I was lazy with the example, my
column actually has 18 digits! Is there anyway that I can expand to 18
digits?




"Gord Dibben" wrote:

> After edit>replace change formatting to Number with no DP.
>
> Your example shows 14 digits..........Excel will handle up to and including
> 15 digits.
>
>
> Gord Dibben MS Excel MVP
>
> On Wed, 17 Feb 2010 11:49:02 -0800, BABs <(E-Mail Removed)>
> wrote:
>
> >This works but changes everything to scientific format or rounds off to the
> >nearest thousand. Can't figure out how to keep the hundreds, tens and ones.
> >????
> >
> >
> >
> >"Ryan H" wrote:
> >
> >> There is a very easy way without using code. I will assume you are using
> >> Excel 2007. Just highlight the column with the hyphenated numbers, click the
> >> Find & Select button in the Home tab on the Ribbon, click Replace, in the
> >> Find What field type -, and leave the Replace With field empty, then click
> >> the Replace All button. That should do it for you.
> >>
> >> Hope this helps! If so, let me know, click "YES" below.
> >> --
> >> Cheers,
> >> Ryan
> >>
> >>
> >> "BABs" wrote:
> >>
> >> > I have a column that has hyphenated numbers (XX-XX-XX-XXX-XXXX) and I need to
> >> > get rid of the hyphens. They are all in the same format so I think if I
> >> > could write code to del the 3rd, 6th, 9th, etc characters from a cell, it
> >> > would work. I just can't seem to figure the code out. or is there an easier
> >> > way?
> >> > Thx.

>
> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autocorrect Number+space to Number+nonbreaking space Kris_Wright_77 Microsoft Word Document Management 1 19th May 2010 07:12 PM
I can't back space more than one character or repeat a character, Onemind Microsoft Word Document Management 1 13th Jan 2010 08:27 PM
Why my space space become funny character?? ivan mm Microsoft Word Document Management 2 3rd Apr 2008 02:17 PM
chr(32) space character is a rectangular box character =?Utf-8?B?SG93IHRvIHJlbmFtZSAyMDA0LnBzdCB0byAyMDA1 Microsoft Word Document Management 0 15th Feb 2005 10:29 AM
delete phone number fields in contacts =?Utf-8?B?Qm9iIE5pY2hvbHM=?= Microsoft Outlook 3 11th Jan 2005 06:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:51 PM.