Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default How can I delete a space/character from a number of fields?

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default How can I delete a space/character from a number of fields?

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" wrote in message
...
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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default How can I delete a space/character from a number of fields?

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.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default How can I delete a space/character from a number of fields?

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.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default How can I delete a space/character from a number of fields?

or if you're looking for a code snippet -


Cells.Replace What:="-", Replacement:="", LookAt:=xlPart, SearchOrder
_
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default How can I delete a space/character from a number of fields?

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.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default How can I delete a space/character from a number of fields?

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.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default How can I delete a space/character from a number of fields?

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


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default How can I delete a space/character from a number of fields?

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.

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default How can I delete a space/character from a number of fields?

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


.



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default How can I delete a space/character from a number of fields?

I was able to use the Replace method just fine. Try formatting all the cells
to Number with decimal place set to 0. Then run the Replace method. Let me
know if this helps, click "YES" below.
--
Cheers,
Ryan


"BABs" wrote:

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
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
is 3rd character in a cell a space? Rick[_10_] Excel Worksheet Functions 5 December 21st 09 07:22 PM
Can i give Space/some other character in between the cell? sumit Excel Worksheet Functions 5 December 9th 08 07:34 AM
How do I replace a BEL Character of 7 with a space KBear Excel Discussion (Misc queries) 1 June 6th 06 03:56 PM
NEED HELP-----Removing a space at the end of a string of character FRS Excel Discussion (Misc queries) 7 April 13th 06 03:57 AM
Detecting the space character JN[_5_] Excel Programming 4 January 17th 06 05:11 PM


All times are GMT +1. The time now is 04:44 PM.

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"