Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default How to remove characters in a cell that precede a specific hyphen

I have a column of cells that have excess data that needs removed. The #of
characters vary. I'm needing a formula to delete all the characters that
precede the 2nd hyphen as well as delete the 2nd hyphen.

Ex. [ABC-12345-12345]

I need the cell to read [12345]

Can anyone provide a formula that can remove this data?

  #2   Report Post  
Posted to microsoft.public.excel.misc
Max Max is offline
external usenet poster
 
Posts: 9,221
Default How to remove characters in a cell that precede a specific hyphen

Presuming your data in A1 down looks like this:
ABC-12345-12344
ABC-12345-12355
etc

In B1:
=MID(A1,SEARCH("-",A1,SEARCH("-",A1)+1)+1,99)+0
Copy down to return the numbers after the 2nd hyphen as real numbers,
viz:
12344
12355
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"brantty" wrote:
I have a column of cells that have excess data that needs removed. The #of
characters vary. I'm needing a formula to delete all the characters that
precede the 2nd hyphen as well as delete the 2nd hyphen.

Ex. [ABC-12345-12345]

I need the cell to read [12345]

Can anyone provide a formula that can remove this data?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default How to remove characters in a cell that precede a specific hyphen

hi,
you said the number of characters vary. could you supply more examples of
the data?

Regards
FSt1

"brantty" wrote:

I have a column of cells that have excess data that needs removed. The #of
characters vary. I'm needing a formula to delete all the characters that
precede the 2nd hyphen as well as delete the 2nd hyphen.

Ex. [ABC-12345-12345]

I need the cell to read [12345]

Can anyone provide a formula that can remove this data?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default How to remove characters in a cell that precede a specific hyp

Max,

This works for most of my data but I have some data that has alpha
characters in them where this formula fails. Can you or FSt1 offer an
adaptation to this formula that allows for alpha characters?

Here's a few more examples

ABA-12345-12345
ABA-C12345-C12345
ABC-18L123-18L123
ABC-Q456789-Q456789



"Max" wrote:

Presuming your data in A1 down looks like this:
ABC-12345-12344
ABC-12345-12355
etc

In B1:
=MID(A1,SEARCH("-",A1,SEARCH("-",A1)+1)+1,99)+0
Copy down to return the numbers after the 2nd hyphen as real numbers,
viz:
12344
12355
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"brantty" wrote:
I have a column of cells that have excess data that needs removed. The #of
characters vary. I'm needing a formula to delete all the characters that
precede the 2nd hyphen as well as delete the 2nd hyphen.

Ex. [ABC-12345-12345]

I need the cell to read [12345]

Can anyone provide a formula that can remove this data?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default How to remove characters in a cell that precede a specific hyp

Here's a few mo

Here's a few more examples

ABA-12345M-12345M
ABA-C12345-C12345
ABC-18L123-18L123
ABC-Q456789JJ-Q456789JJ


"FSt1" wrote:

hi,
you said the number of characters vary. could you supply more examples of
the data?

Regards
FSt1

"brantty" wrote:

I have a column of cells that have excess data that needs removed. The #of
characters vary. I'm needing a formula to delete all the characters that
precede the 2nd hyphen as well as delete the 2nd hyphen.

Ex. [ABC-12345-12345]

I need the cell to read [12345]

Can anyone provide a formula that can remove this data?



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default How to remove characters in a cell that precede a specific hyp

And one more example that has a zero.

ABC-07901-07901

I need the zero to stay with the number, thus the result to be: 07901.

thanks for your help

"FSt1" wrote:

hi,
you said the number of characters vary. could you supply more examples of
the data?

Regards
FSt1

"brantty" wrote:

I have a column of cells that have excess data that needs removed. The #of
characters vary. I'm needing a formula to delete all the characters that
precede the 2nd hyphen as well as delete the 2nd hyphen.

Ex. [ABC-12345-12345]

I need the cell to read [12345]

Can anyone provide a formula that can remove this data?

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default How to remove characters in a cell that precede a specific hyphen

On Thu, 3 Apr 2008 17:16:24 -0700, brantty
wrote:

I have a column of cells that have excess data that needs removed. The #of
characters vary. I'm needing a formula to delete all the characters that
precede the 2nd hyphen as well as delete the 2nd hyphen.

Ex. [ABC-12345-12345]

I need the cell to read [12345]

Can anyone provide a formula that can remove this data?


Assuming that your brackets [ ] are not really part of the value, then:

=MID(A1,FIND(CHAR(1),SUBSTITUTE(A1,"-",CHAR(1),2))+1,255)

will return everything after the 2nd hyphen.

--ron
  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default How to remove characters in a cell that precede a specific hyphen

If you always want to keep the characters after the last (no matter how many)
hyphen...

And you don't have to use a formula, you could use:

Select the range to fix
edit|replace
what: *- (asterisk, hyphen)
with: (leave blank)
replace all



brantty wrote:

I have a column of cells that have excess data that needs removed. The #of
characters vary. I'm needing a formula to delete all the characters that
precede the 2nd hyphen as well as delete the 2nd hyphen.

Ex. [ABC-12345-12345]

I need the cell to read [12345]

Can anyone provide a formula that can remove this data?


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default How to remove characters in a cell that precede a specific hyp

Ron, You are awesome. Great work. Its working exactly as I needed.

Ty

"Ron Rosenfeld" wrote:

On Thu, 3 Apr 2008 17:16:24 -0700, brantty
wrote:

I have a column of cells that have excess data that needs removed. The #of
characters vary. I'm needing a formula to delete all the characters that
precede the 2nd hyphen as well as delete the 2nd hyphen.

Ex. [ABC-12345-12345]

I need the cell to read [12345]

Can anyone provide a formula that can remove this data?


Assuming that your brackets [ ] are not really part of the value, then:

=MID(A1,FIND(CHAR(1),SUBSTITUTE(A1,"-",CHAR(1),2))+1,255)

will return everything after the 2nd hyphen.

--ron

  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15,768
Default How to remove characters in a cell that precede a specific hyp

Try this:

=MID(A1,FIND("-",A1,FIND("-",A1)+1)+1,255)


--
Biff
Microsoft Excel MVP


"brantty" wrote in message
...
And one more example that has a zero.

ABC-07901-07901

I need the zero to stay with the number, thus the result to be: 07901.

thanks for your help

"FSt1" wrote:

hi,
you said the number of characters vary. could you supply more examples of
the data?

Regards
FSt1

"brantty" wrote:

I have a column of cells that have excess data that needs removed. The
#of
characters vary. I'm needing a formula to delete all the characters
that
precede the 2nd hyphen as well as delete the 2nd hyphen.

Ex. [ABC-12345-12345]

I need the cell to read [12345]

Can anyone provide a formula that can remove this data?





  #11   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 747
Default How to remove characters in a cell that precede a specific hyp

Might help u

If A1 = ABA-12345M-12345M

IN B1 =MID(A1,SEARCH("-",A1,SEARCH("-",A1,SEARCH("-",A1)+1))+1,99)



On Apr 4, 7:10*am, brantty wrote:
Here's a few mo

Here's a few more examples

ABA-12345M-12345M
ABA-C12345-C12345
ABC-18L123-18L123
ABC-Q456789JJ-Q456789JJ



"FSt1" wrote:
hi,
you said the number of characters vary. could you supply more examples of
the data?


Regards
FSt1


"brantty" wrote:


I have a column of cells that have excess data that needs removed. *The #of
characters vary. *I'm needing a formula to delete all the characters that
precede the 2nd hyphen as well as delete the 2nd hyphen.


Ex. * [ABC-12345-12345]


I need the cell to read [12345]


Can anyone provide a formula that can remove this data?- Hide quoted text -


- Show quoted text -


  #12   Report Post  
Posted to microsoft.public.excel.misc
Max Max is offline
external usenet poster
 
Posts: 9,221
Default How to remove characters in a cell that precede a specific hyp

You just need to remove the "+0" from the earlier,
viz use in B1, copied down:
=MID(A1,SEARCH("-",A1,SEARCH("-",A1)+1)+1,99)
(All extracts in col B will be in text)

Anyway, I see you have since received an answer you like
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"brantty" wrote in message
...
Max,

This works for most of my data but I have some data that has alpha
characters in them where this formula fails. Can you or FSt1 offer an
adaptation to this formula that allows for alpha characters?

Here's a few more examples

ABA-12345-12345
ABA-C12345-C12345
ABC-18L123-18L123
ABC-Q456789-Q456789



  #13   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default How to remove characters in a cell that precede a specific hyp

Ron,

I found some cells that were different,. Instead of looking for the 2nd
hypen, can you adapt a formula to keep all data after the LAST hyphen?

Ty

"Ron Rosenfeld" wrote:

On Thu, 3 Apr 2008 17:16:24 -0700, brantty
wrote:

I have a column of cells that have excess data that needs removed. The #of
characters vary. I'm needing a formula to delete all the characters that
precede the 2nd hyphen as well as delete the 2nd hyphen.

Ex. [ABC-12345-12345]

I need the cell to read [12345]

Can anyone provide a formula that can remove this data?


Assuming that your brackets [ ] are not really part of the value, then:

=MID(A1,FIND(CHAR(1),SUBSTITUTE(A1,"-",CHAR(1),2))+1,255)

will return everything after the 2nd hyphen.

--ron

  #14   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15,768
Default How to remove characters in a cell that precede a specific hyp

Try this:

=MID(A1,FIND("~~",SUBSTITUTE(A1,"-","~~",LEN(A1)-LEN(SUBSTITUTE(A1,"-",""))))+1,255)

Assumes there is at least 1 hypen.


--
Biff
Microsoft Excel MVP


"brantty" wrote in message
...
Ron,

I found some cells that were different,. Instead of looking for the 2nd
hypen, can you adapt a formula to keep all data after the LAST hyphen?

Ty

"Ron Rosenfeld" wrote:

On Thu, 3 Apr 2008 17:16:24 -0700, brantty

wrote:

I have a column of cells that have excess data that needs removed. The
#of
characters vary. I'm needing a formula to delete all the characters
that
precede the 2nd hyphen as well as delete the 2nd hyphen.

Ex. [ABC-12345-12345]

I need the cell to read [12345]

Can anyone provide a formula that can remove this data?


Assuming that your brackets [ ] are not really part of the value, then:

=MID(A1,FIND(CHAR(1),SUBSTITUTE(A1,"-",CHAR(1),2))+1,255)

will return everything after the 2nd hyphen.

--ron



  #15   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 747
Default How to remove characters in a cell that precede a specific hyp

Use this

=MID(A1,FIND("-",A1)+1,99)



On Apr 4, 8:06*am, brantty wrote:
Ron, *

I found some cells that were different,. *Instead of looking for the 2nd
hypen, can you adapt a formula to keep all data after the LAST hyphen?

Ty



"Ron Rosenfeld" wrote:
On Thu, 3 Apr 2008 17:16:24 -0700, brantty
wrote:


I have a column of cells that have excess data that needs removed. *The #of
characters vary. *I'm needing a formula to delete all the characters that
precede the 2nd hyphen as well as delete the 2nd hyphen.


Ex. * [ABC-12345-12345]


I need the cell to read [12345]


Can anyone provide a formula that can remove this data?


Assuming that your brackets *[ *] are not really part of the value, then:


=MID(A1,FIND(CHAR(1),SUBSTITUTE(A1,"-",CHAR(1),2))+1,255)


will return everything after the 2nd hyphen.


--ron- Hide quoted text -


- Show quoted text -




  #16   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default How to remove characters in a cell that precede a specific hyp

On Thu, 3 Apr 2008 19:34:01 -0700, brantty
wrote:

Ron, You are awesome. Great work. Its working exactly as I needed.

Ty


Glad to help. Thanks for the feedback.
--ron
  #17   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default How to remove characters in a cell that precede a specific hyp

On Thu, 3 Apr 2008 20:06:01 -0700, brantty
wrote:

Ron,

I found some cells that were different,. Instead of looking for the 2nd
hypen, can you adapt a formula to keep all data after the LAST hyphen?

Ty


Yep. It's just a matter of changing the "2" (for the 2nd hyphen) to a formula
that calculates the number of hyphens:



=MID(A1,FIND(CHAR(1),SUBSTITUTE(A1,"-",CHAR(1),
LEN(A1)-LEN(SUBSTITUTE(A1,"-",""))))+1,255)
--ron
  #18   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Hyphens problem

a1 = ABC-12345-12345

ANSWER IS

=mid(a1,54,5) and
answer = 12345
  #19   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,651
Default Hyphens problem

If that is the answer, then I am confused about what the question is? :-)
--
David Biddulph

<Suraj Noorsai wrote in message
...
a1 = ABC-12345-12345

ANSWER IS

=mid(a1,54,5) and
answer = 12345



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
Remove Characters Until a Specific Character is Reached Frosty 1234 Excel Worksheet Functions 8 April 4th 23 12:50 PM
Remove Characters from a cell Kim Excel Worksheet Functions 8 June 1st 06 05:21 PM
remove non-numeric characters from a cell SWBodager Excel Discussion (Misc queries) 14 December 16th 05 07:49 PM
remove last three characters of cell mira Excel Discussion (Misc queries) 8 July 28th 05 12:06 AM
Need to remove hyphen in group of #s [email protected] Excel Discussion (Misc queries) 2 March 2nd 05 02:04 PM


All times are GMT +1. The time now is 01:23 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"