+ Reply to Thread
Results 1 to 27 of 27

Colour extract

  1. #1
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,616

    Colour extract

    This on a1

    CL797C36
    CL797C37
    CL797C38
    CL797C39
    CL797C40
    CL797C41
    CL797RD36

    Want this on b1 downwards

    C
    C
    C
    C
    C
    C
    RD

  2. #2
    Forum Expert cbatrody's Avatar
    Join Date
    04-15-2014
    Location
    Dubai
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    2,136

    Re: Colour extract

    Hi,

    Try the following formula in B1:

    =IF(LEN(A1)=9,MID(A1,6,2),MID(A1,6,1))

  3. #3
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,616

    Re: Colour extract

    Worked almost on most codes except this one

    CL0414C36

    It pulled 4C instead of C only

  4. #4
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Colour extract

    Yah, well, waddaya expect? How about you define the rules and the logic to be used? We can help with the formulas, but YOU need to provide the business rules.

    So, for
    CL797C36 you want to return 'C'

    for
    CL797RD36 you want to return 'RD'

    At first glance it seemed to be a matter of how many characters are in the string: if the string has 9 characters, get the two characters at position 6 and 7, otherwise get the character at position 6.

    Now you throw in another example that changes the goal posts.


    for
    CL0414C36 you want to return 'C'

    So you need to re-define the goal posts.

    What are the rules?

    cheers, teylyn

  5. #5
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Colour extract

    It depends how many other variations there are, if it is always 5 characters before, 2 characters after, then this should work.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    There are probably a few other combinations of left, right, and mid that work as well.

  6. #6
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Colour extract

    deleted the post
    Last edited by samba_ravi; 10-09-2015 at 06:11 AM.
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  7. #7
    Forum Expert cbatrody's Avatar
    Join Date
    04-15-2014
    Location
    Dubai
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    2,136

    Re: Colour extract

    Try the following in B1:

    =IF(ISNUMBER(1*MID(A1,6,1)),MID(A1,7,1),IF(LEN(A1)=9,MID(A1,6,2),MID(A1,6,1)))

  8. #8
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Colour extract

    B1=MID(SUBSTITUTE(A1,LOOKUP(9^9,RIGHT(A1,ROW(INDIRECT("1:"&LEN(A1))))+0,RIGHT(A1,ROW(INDIRECT("1:"&LEN(A1))))+0),""),LOOKUP(1,1/MID(SUBSTITUTE(A1,LOOKUP(9^9,RIGHT(A1,ROW(INDIRECT("1:"&LEN(A1))))+0,RIGHT(A1,ROW(INDIRECT("1:"&LEN(A1))))+0),""),ROW(INDIRECT("1:"&LEN(A1))),1)+0,ROW(INDIRECT("1:"&LEN(A1))))+1,LEN(A1))
    Please Login or Register  to view this content.
    Tryt this and copy towards down

  9. #9
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Colour extract

    B1=MID(SUBSTITUTE(A1,LOOKUP(9^9,RIGHT(A1,ROW(INDIRECT("1:"&LEN(A1))))+0,RIGHT(A1,ROW(INDIRECT("1:"&LEN(A1))))+0),""),LOOKUP(1,1/MID(SUBSTITUTE(A1,LOOKUP(9^9,RIGHT(A1,ROW(INDIRECT("1:"&LEN(A1))))+0,RIGHT(A1,ROW(INDIRECT("1:"&LEN(A1))))+0),""),ROW(INDIRECT("1:"&LEN(A1))),1)+0,ROW(INDIRECT("1:"&LEN(A1))))+1,LEN(A1))
    Please Login or Register  to view this content.
    Tryt this and copy towards down

  10. #10
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Colour extract

    Data Range
    A
    B
    1
    CL797C36
    C
    2
    CL797C37
    C
    3
    CL797C38
    C
    4
    CL797C39
    C
    5
    CL797C40
    C
    6
    CL797C41
    C
    7
    CL797RD36
    RD
    8

    Data Range
    B
    1
    =MID(A1,6,MAX((LEN(A1)-2)-6+1,0))


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  11. #11
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Colour extract

    Quote Originally Posted by nflsales View Post
    Tryt this and copy towards down
    Why post the formula 4 times? The first was clearly visible.

    If nothing else you get the longest formula in the thread award

  12. #12
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Colour extract

    Quote Originally Posted by jason.b75 View Post
    Why post the formula 4 times? The first was clearly visible.

    If nothing else you get the longest formula in the thread award
    While posting the formula I got some error that's why it was happen,

    Please give shorter formula rather than commenting on the formula posted by me, a sweet comment will be acceptable but not criticism.
    Is your formula "=RIGHT(LEFT(A1,LEN(A1)-2),LEN(A1)-7)" fulfilling the OPs requirement as post No.3 [CL0414C36 It pulled 4C instead of C only]

  13. #13
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Colour extract

    Why don't you all wait for the OP to come back with their business logic instead of jumping the gun and wildly guessing what you think the OP may need? What's the urge?

    And also, we're approaching the weekend, which means that the forum goes into glitch frenzy. Multiple repetitions of posts are the result of forum software problems, and NOT due to a member posting duplicates.

    Keep it calm.

    This place should be about quality, not speed.

    cheers, teylyn

  14. #14
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Colour extract

    Quote Originally Posted by :) Sixthsense :) View Post
    Data Range
    A
    B
    1
    CL797C36
    C
    2
    CL797C37
    C
    3
    CL797C38
    C
    4
    CL797C39
    C
    5
    CL797C40
    C
    6
    CL797C41
    C
    7
    CL797RD36
    RD
    8

    Data Range
    B
    1
    =MID(A1,6,MAX((LEN(A1)-2)-6+1,0))

    Well, how about post #3 then?

  15. #15
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Colour extract

    Quote Originally Posted by teylyn View Post
    Well, how about post #3 then?
    I used 3 functions whereas in Post #3 it was 4 lol

  16. #16
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,616

    Re: Colour extract

    The only one that worked was this one by CBTRODY

    Please Login or Register  to view this content.

  17. #17
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,616

    Re: Colour extract

    It pulled C on CL0414C36 while the other formula by others pulled 4C
    It takes cares of the length of description regardless

  18. #18
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,616

    Re: Colour extract

    Ouch but it pulls T instead of TN on this

    KD646TN2

  19. #19
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,616

    Re: Colour extract

    Here is the file attached in case to see character variations
    Attached Files Attached Files

  20. #20
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Colour extract

    Quote Originally Posted by nflsales View Post
    Please give shorter formula rather than commenting on the formula posted by me, a sweet comment will be acceptable but not criticism.
    Is your formula "=RIGHT(LEFT(A1,LEN(A1)-2),LEN(A1)-7)" fulfilling the OPs requirement as post No.3 [CL0414C36 It pulled 4C instead of C only]
    I missed that example in post #3. I will give criticism and accept it where given to me, I know I make mistakes, and I like to know when I do.

    Giving a sweet comment to a bad answer is like praising a pet that has just left a smelly package in your brand new carpet

    The OP has accepted a solution, which, in my opinion, doesn't need improving so no point in trying to find and posting another.

  21. #21
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Colour extract

    B1
    Please Login or Register  to view this content.

  22. #22
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,616

    Re: Colour extract

    wow NFSALES , this is it

  23. #23
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,616

    Re: Colour extract

    It even took care of this

    CM122DBR41 DBR

  24. #24
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Colour extract

    makinmomb,

    you threw a question at us and several folks attempted to answer it.

    There were a few questions for clarification. You seemed to ignore these.

    Your issue is not straightforward. You need to answer our questions so we can address your issue.

    Please review the posts above and address the questions posted by people who are trying to help you.

  25. #25
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Colour extract

    Quote Originally Posted by teylyn View Post
    There were a few questions for clarification. You seemed to ignore these.

    Your issue is not straightforward. You need to answer our questions so we can address your issue.
    It was straightforward enough,
    4 part string consisting of text & number & text & number, with no delimiters to make use of.
    Requirement to return the second text portion, i.e. the third part of the string.

    You were the only person that asked more questions, everyone else figured it out easily enough, we were all just guilty of posting answers without testing them properly.

    I may have harshly criticised nflsales earlier attempt (whilst failing to see the flaws in my own offering), but their latest was accepted by the OP as returning all of the results as expected.

  26. #26
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Colour extract

    Jason, I'm trying to encourage the OP to clearly state the requirements, instead of letting us guess what the result should be. Yes, I did figure it out, too. I just wanted the OP to confirm the assumptions we all made. I've been in the business long enough to know that sometimes a half dozen examples does NOT cover all the possibilities of the real world.

    Not trying to be difficult, but wanting as much info as possible to avoid wasting time on wild goose chases.

  27. #27
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Colour extract

    Just found this in another thread
    Quote Originally Posted by Richard Buttrey View Post
    One such rule might be return the characters before the first digit
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    I've only just upgraded from excel 2007 so not had much chance to figure out the aggregate function, but the one above got me thinking that it could be applied here.

    Bearing in mind this is my first attempt at an aggregate derived formula, there is probably room for improvement, but it does return all of the correct results, and I don't think any of the functions are volatile.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    It is (slightly) shorter than nflsales formula, and does appear to be slightly more efficient, but I haven't done performance testing, only compared results.

    edit:-

    One subsequent observation, the formula will not recognise lower case characters, a failsafe here, if needed would be to change the 2nd and 6th instances of A1 to UPPER(A1).

    The formula can be shortened quite a bit if the string will always have 2 letters before the first number.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Note that this short version doesn't include the lower case character failsafe mentioned above, although it could still be applied.
    Last edited by jason.b75; 10-10-2015 at 06:04 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 02-13-2015, 03:06 PM
  2. VBA to colour data labels same as line colour - dynamic chart
    By Jabba69 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-06-2014, 10:59 AM
  3. Replies: 3
    Last Post: 02-13-2014, 06:31 AM
  4. Replies: 1
    Last Post: 09-12-2013, 02:09 PM
  5. Replies: 2
    Last Post: 06-07-2011, 07:00 AM
  6. Extract Cell Font/Background Colour
    By icu222much in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 07-02-2010, 11:17 PM
  7. Replies: 3
    Last Post: 07-15-2009, 06:13 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1