Any MS Excel experts, please help.
Any MS Excel experts, please help.
Author
Discussion

megy

Original Poster:

2,429 posts

245 months

Thursday 31st May 2007
quotequote all
Hello, I am working through a list of about 100,000 part numbers in 3 Excel spreadsheets, and now I have just been told I need to seperate some with a certain layout.

I need to find and seperate any part number with a '-' between a letter and a letter, a '-' between a number and a letter(or vice versa) is ok, as is a '-' between a number and a number.

I have tried using the auto filter, but the wildcard (?) character is not specific to denote a letter or number, instead just any character.

Does anyone know a way i can get this filtered or a formaula that will enable me to do this?

Thanks in advance for any assistance.

Road2Ruin

6,588 posts

247 months

Thursday 31st May 2007
quotequote all
That one has fooled me. However, there may be a way by instead of filtering get excel to sort them instead as it usually does numbers first then letters, then letter followed by number, then finally letters followed by letters. So should leave all of your letters-letters at the bottom, maybe. Give it a try.
Pete

Munter

31,331 posts

272 months

Thursday 31st May 2007
quotequote all
I'd import them into access and do it using a query. Lots more options on how to do it then.

I'd do it the dumb way with lots of is the character a or b or etc to make the rule you want.

I'm sure theres a clever way to do it in excel though.

Vee

3,109 posts

265 months

Thursday 31st May 2007
quotequote all
Pretty straightforward.
If Cell A2 contains 1234-5678 then the following steps seem to work . .

In cell B2, ID left of "-" : =RIGHT(LEFT(A2,(FIND("-",A2)-1)),1)
In cell C2, use VLOOKUP on a list to identify whether a Letter or Number. I sumply created a list in colJ of a-z and 0-9. In colK, I put whether the character in colJ was a Letter ot Number see example below: =VLOOKUP(B2,J:K,2,0)

In cell D2, ID right of "-" : =LEFT(RIGHT(A2,LEN(A2)-(FIND("-",A2))),1)
In cell E2, use VLOOKUP to identify whether letter or number : =VLOOKUP(D2,J:K,2,0)

Finally combine colsC and E in cell F2 : =C2&E2. This will form on of 4 combinations and you can apply an AutoFilter.

ColJ ColK
a Letter
b Letter
c Letter

I've a simple file set up, send me your email and I'll mail it to you.
and so on

megy

Original Poster:

2,429 posts

245 months

Thursday 31st May 2007
quotequote all
Thanks Vee,

Works a treat on a sample of a few numbers I took out for a trial, will be putting it into the full versions later on. You have saved me a lot of visual searching.

plasticpig

12,932 posts

256 months

Thursday 31st May 2007
quotequote all
Vee said:
Pretty straightforward.
If Cell A2 contains 1234-5678 then the following steps seem to work . .

In cell B2, ID left of "-" : =RIGHT(LEFT(A2,(FIND("-",A2)-1)),1)
In cell C2, use VLOOKUP on a list to identify whether a Letter or Number. I sumply created a list in colJ of a-z and 0-9. In colK, I put whether the character in colJ was a Letter ot Number see example below: =VLOOKUP(B2,J:K,2,0)

In cell D2, ID right of "-" : =LEFT(RIGHT(A2,LEN(A2)-(FIND("-",A2))),1)
In cell E2, use VLOOKUP to identify whether letter or number : =VLOOKUP(D2,J:K,2,0)

Finally combine colsC and E in cell F2 : =C2&E2. This will form on of 4 combinations and you can apply an AutoFilter.

ColJ ColK
a Letter
b Letter
c Letter

I've a simple file set up, send me your email and I'll mail it to you.
and so on
I have an alternative solution which uses a single cell. The formula returns a booleand value. True if it matches the Alpha-Alpha criteria and false if it dosent.
The formula is:

=IF(FIND("-",A1,1),AND(OR(CODE(MID(A1,FIND("-",A1,1)+1,1)) <48,CODE(MID(A1,FIND("-",A1,1)+1,1)) >57),OR(CODE(MID(A1,FIND("-",A1,1)-1,1)) <48,CODE(MID(A1,FIND("-",A1,1)-1,1)) >57)),FALSE)

Where A1 is the cell reference that contains the part number.



Vee

3,109 posts

265 months

Thursday 31st May 2007
quotequote all
PP - beyond my capabilities I'm afraid !

Jinx

12,023 posts

291 months

Thursday 31st May 2007
quotequote all
PP - now I understand it thumbup The find function finds the dash and returns it's position, the code and mid returns the codes for the string characters either side (code returns a number for the first character of any string from i.e. code( "9" ) = 57 and code ( "A" ) = 65) and all the or's and and's create the scenario of which two letter characters return the "True" value.
Though it might need a < 123 and something to knock out the 91 - 96 range as these are special characters that will still return a True value.


Edited by Jinx on Thursday 31st May 16:27

plasticpig

12,932 posts

256 months

Thursday 31st May 2007
quotequote all
Jinx said:
PP - now I understand it thumbup The find function finds the dash and returns it's position, the code and mid returns the codes for the string characters either side (code returns a number for the first character of any string from i.e. code( "9" ) = 57 and code ( "A" ) = 65) and all the or's and and's create the scenario of which two letter characters return the "True" value.
Though it might need a < 123 and something to knock out the 91 - 96 range as these are special characters that will still return a True value.


Edited by Jinx on Thursday 31st May 16:27
Yes thats right. It might need to filter out other characters if they are in the part numbers. But from what the OP said part numbers consist of Letters, Numbers and "-" so I didn't consider any other filtering.

megy

Original Poster:

2,429 posts

245 months

Thursday 31st May 2007
quotequote all
plasticpig said:
I have an alternative solution which uses a single cell. The formula returns a booleand value. True if it matches the Alpha-Alpha criteria and false if it dosent.
The formula is:

=IF(FIND("-",A1,1),AND(OR(CODE(MID(A1,FIND("-",A1,1)+1,1)) <48,CODE(MID(A1,FIND("-",A1,1)+1,1)) >57),OR(CODE(MID(A1,FIND("-",A1,1)-1,1)) <48,CODE(MID(A1,FIND("-",A1,1)-1,1)) >57)),FALSE)

Where A1 is the cell reference that contains the part number.
PP, Thanks to you also, both ways work well, and have totally gone way over my head, guess thats why I work as an aircraft engineer and not a programmer or something similar.

Thanks to both you and VEE

megy

Original Poster:

2,429 posts

245 months

Friday 14th September 2007
quotequote all
plasticpig said:
I have an alternative solution which uses a single cell. The formula returns a booleand value. True if it matches the Alpha-Alpha criteria and false if it dosent.
The formula is:

=IF(FIND("-",A1,1),AND(OR(CODE(MID(A1,FIND("-",A1,1)+1,1)) <48,CODE(MID(A1,FIND("-",A1,1)+1,1)) >57),OR(CODE(MID(A1,FIND("-",A1,1)-1,1)) <48,CODE(MID(A1,FIND("-",A1,1)-1,1)) >57)),FALSE)

Where A1 is the cell reference that contains the part number.
Hi PP, are either you, or anyone else on here able to adapt the above formula to show a '-' between a alpha/numeric and/or a numeric/alpha(but to disregard a '-' between a numeric/numeric.

Heres hoping.

plasticpig

12,932 posts

256 months

Friday 14th September 2007
quotequote all
megy said:
plasticpig said:
I have an alternative solution which uses a single cell. The formula returns a booleand value. True if it matches the Alpha-Alpha criteria and false if it dosent.
The formula is:

=IF(FIND("-",A1,1),AND(OR(CODE(MID(A1,FIND("-",A1,1)+1,1)) <48,CODE(MID(A1,FIND("-",A1,1)+1,1)) >57),OR(CODE(MID(A1,FIND("-",A1,1)-1,1)) <48,CODE(MID(A1,FIND("-",A1,1)-1,1)) >57)),FALSE)

Where A1 is the cell reference that contains the part number.
Hi PP, are either you, or anyone else on here able to adapt the above formula to show a '-' between a alpha/numeric and/or a numeric/alpha(but to disregard a '-' between a numeric/numeric.

Heres hoping.
You dont mention wehether you want to dispaly ALPHA-ALPHA

If you do then:

=IF(NOT(ISERROR(FIND("-",A1,1))),NOT(AND(AND(CODE(MID(A1,FIND("-",A1,1)+1,1))>=48,CODE(MID(A1,FIND("-",A1,1)+1,1)) <=57),AND(CODE(MID(A1,FIND("-",A1,1)-1,1))>=48,CODE(MID(A1,FIND("-",A1,1)-1,1)) <=57))),FALSE)

IF you dont then:

=IF(NOT(ISERROR(FIND("-",A1,1))),OR(AND(OR(CODE(MID(A1,FIND("-",A1,1)-1,1))<48,CODE(MID(A1,FIND("-",A1,1)-1,1))>57),AND(CODE(MID(A1,FIND("-",A1,1)+1,1))>=48,CODE(MID(A1,FIND("-",A1,1)+1,1))<=57)),AND(OR(CODE(MID(A1,FIND("-",A1,1)+1,1))<48,CODE(MID(A1,FIND("-",A1,1)+1,1))>57),AND(CODE(MID(A1,FIND("-",A1,1)-1,1))>=48,CODE(MID(A1,FIND("-",A1,1)-1,1))<=57))),FALSE)

megy

Original Poster:

2,429 posts

245 months

Monday 17th September 2007
quotequote all
Thanks, PP, I am about to try it but I dont doubt it will be wrong, so thank you so much for this, you are a star.