+ Reply to Thread
Results 1 to 15 of 15

Lookup specific text in a cell and highlight

  1. #1
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Lookup specific text in a cell and highlight

    Hi,

    Currently I have several formulas in use but the principle will be the same.

    Formulas in this example are:
    =(COUNTIF($I1,"*TCN*A*")+COUNTIF($I1,"*A*TCN*"))>0
    =COUNTIF($I1,"A**********")

    The reference number starting with A will always have 10 digits and always start with A - A1234567890
    Reference number with TCN will always start TCN and always have 5 digits - TCN12345

    Sheet 1 Rows 7&8 shows using the above formulas the rows will highlight green when these reference numbers are found, however, Rows 11&12 show they still show green when the reference numbers are typed incorrect.

    Sheet 2 uses no formulas but just shows required results.

    Is there a way to lookup a specific number of digits in a cell and return false if format is incorrect?

    Duplicate post
    https://www.excelforum.com/excel-pro...g-in-cell.html
    solved with VBA but still interested to see if it can be done with formula so conditional formatting can be used.

    Thanks
    Attached Files Attached Files
    Last edited by ~TaC~; 08-18-2019 at 12:23 PM.

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

    Re: Lookup specific text in a cell and highlight

    Try this for your formatting rule
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Note that this is still not perfect, it looks at the number of characters, but not what the characters are. To validate all of the characters as numeric, you would have to check each character individually which will require some far more complex (and inefficient) formulas.

    With conditional formatting, you don't need to test true or false, any non zero number will evaluate to true. Zero, text or errors will default to false.

  3. #3
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: Lookup specific text in a cell and highlight

    @jason.b75 thanks for your reply but your formula results in only A6 & A7 highlighting??

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

    Re: Lookup specific text in a cell and highlight

    Sorry, missing $ symbols

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: Lookup specific text in a cell and highlight

    Thanks, fixed the problem, however.

    Formula highlights row if one or the other is correct. So if one reference is incorrect it still highlights row, if that makes sense.

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

    Re: Lookup specific text in a cell and highlight

    I think that this should work for incorrect TCN references,
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    But not sure about A references,
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    If, as per your sample, it will always be both refernces with no other text, or just an A reference at the end of a cell with other text then I can probably make it a bit more reliable, if this is not the case then I think there will always be exceptions that can slip through.

  7. #7
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: Lookup specific text in a cell and highlight

    Those formulas aren't working for me, highlights entire selected range??

    It will always be A reference and TCN reference, or just A reference. Could contain other text but needs to check for these correct references to flag up errors.

    Another option if possible could be to look up more/less than 10 or 5 digits and highlight the error rather than a correct entry, this way it might be possible to use separate formulas for A ref and TCN ref that highlights a non match??

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

    Re: Lookup specific text in a cell and highlight

    As I said previously, it is not an easy task to identify digits in a cell with mixed data. You can only identify numbers as numbers if there is no other text in the cell.

    Using 2 separate rules will not work, that would create an error on row 8 as there is no TCN.

    I'll give it some more thought, but I think that you might need vba to make this work.

  9. #9
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: Lookup specific text in a cell and highlight

    Thanks for your patience, I initially thought there would be a way to look up a specific number of characters but I see its not an easy one.

    I was thinking it might be a case of VBA but figured I'd try here first.

  10. #10
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: Lookup specific text in a cell and highlight

    So just thinking about the way I described this I may have confused things slightly when talking about specific numbers.

    Let's try this, is there a formula that can be used to highlight if the number of digits after the 'A' & 'TCN' doesn't equal 10 & 5 respectively?

    Thanks

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Lookup specific text in a cell and highlight

    I came across this thread, accidentally, when searching for something else. Dunno if you're still interested, but see if this does what you had hoped for...

    Seems to have been a bit of a "shouty" thread!!
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  12. #12
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: Lookup specific text in a cell and highlight

    Thanks for your reply, seems to have a lot of calculations in this formula to make it work. Great job.

    Yeah it went a tad shouty.

    Currently have it working through VBA but always nice to see how things can work. I see it only looks up the amount of numbers not specifically the preceding A or TCN so I'll put it in to my workbook and have a play with it.

    Thanks again.

    Tez

  13. #13
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Lookup specific text in a cell and highlight

    Yea. I realised that after I'd posted. It can be modified, if you wish to finish the job via formula... if you're interested.

    If not... You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

  14. #14
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: Lookup specific text in a cell and highlight

    Yeah I'd be interested in modified formula, currently having problems with macro's and protected sheets so less macro's the better lol

  15. #15
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Lookup specific text in a cell and highlight

    The modified formula is now in place. Many formulae fail if there are more than 1 set of numbers in a cell, or if the number has a leading zero (e.g. TCN01234).

    The basic structure is:

    =AND(I2<>"",NOT(OR(ISNUMBER(SEARCH(10-digit number,I2),ISNUMBER(SEARCH(5-digit number,I2)))

    where the bits in red are the bits in theformula that do the donkey work...
    Attached Files Attached Files

+ 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. [SOLVED] How to highlight a specific cell based on value/text/number
    By Byambadorj in forum Excel General
    Replies: 13
    Last Post: 07-18-2018, 03:41 AM
  2. [SOLVED] Highlight specific cells if cell contains text or numbers
    By besis in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-18-2018, 12:00 PM
  3. Check a webpage for specific text and highlight a cell based on result
    By ks100 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-12-2013, 09:56 AM
  4. Using VBA to highlight specific text in cell
    By nav505 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-11-2013, 03:28 AM
  5. Replies: 3
    Last Post: 08-02-2013, 12:43 PM
  6. Specific Text in Range then highlight cell
    By gingank in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-11-2013, 10:41 AM
  7. [SOLVED] Highlight a range of cells if a single cell contains specific text
    By ZHertz in forum Excel General
    Replies: 3
    Last Post: 10-19-2012, 02:54 PM

Tags for this Thread

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