+ Reply to Thread
Results 1 to 17 of 17

if part of text is in red color then true

  1. #1
    Registered User
    Join Date
    06-07-2018
    Location
    singapore
    MS-Off Ver
    2000
    Posts
    11

    if part of text is in red color then true

    hi,

    I have an excel file which column A have thousands row of cells need to check if part of text is in RED color then show result as True else False.

    I would like to have a macro to do it.

    Sample:

    ABC123,OK=123 True
    123-dcvfg-a=123,456-tgb-b=234 False

    I'm currently using formula to do it, but is fail when part of the text is not red.

    my way is at below:
    excel formula =txtColor(A1370)

    Function txtColor(rng As Range)
    txtColor = rng.Font.ColorIndex
    End Function

  2. #2
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: if part of text is in red color then true

    I don't know how you can check part of the cell for red text. Is there something that defines where the red text may appear within the cell? Delimited?

  3. #3
    Registered User
    Join Date
    06-07-2018
    Location
    singapore
    MS-Off Ver
    2000
    Posts
    11
    Hi,

    It does not have common pattern.

  4. #4
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: if part of text is in red color then true

    What is making it RED?

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: if part of text is in red color then true

    Use in cell like
    =FindPartColor(A1,3)
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    06-07-2018
    Location
    singapore
    MS-Off Ver
    2000
    Posts
    11

    Thumbs up Re: if part of text is in red color then true

    hi,

    It works perfectly! thanks a million!

  7. #7
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: if part of text is in red color then true

    try
    Please Login or Register  to view this content.
    damn too slow again!

    note you are using excel quite oddly to be having parts of cells partly coloured and then needing to know which cells are like that, you should try to avoid doing things like that if possible.
    Last edited by scottiex; 06-08-2018 at 12:24 AM.
    If you want something done right... find a forum and ask an online expert.

    Time flies like an arrow. Fruit flies like a banana.

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: if part of text is in red color then true

    You are welcome.

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

  9. #9
    Registered User
    Join Date
    06-07-2018
    Location
    singapore
    MS-Off Ver
    2000
    Posts
    11
    Quote Originally Posted by jindon View Post
    You are welcome.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.
    I wrote a macro to execute these, however the result is #name?. Why?

  10. #10
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: if part of text is in red color then true

    Quote Originally Posted by asterkhor View Post
    hi,

    It works perfectly! thanks a million!
    What happened?

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: if part of text is in red color then true

    Quote Originally Posted by asterkhor View Post
    I wrote a macro to execute these, however the result is #name?. Why?
    How did you write it?
    #name? appears when function name is wrongly entered in the cell.

  12. #12
    Registered User
    Join Date
    06-07-2018
    Location
    singapore
    MS-Off Ver
    2000
    Posts
    11

    Re: if part of text is in red color then true

    hi,

    I close the app and rerun macro, it works again.

    but it's a bit weird, it appear #value? for 1 or 2 second, then it works again.

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: if part of text is in red color then true

    I close the app and rerun macro, it works again.
    Without seeing how you wrote it, no one can even guess what is going on.

  14. #14
    Registered User
    Join Date
    06-07-2018
    Location
    singapore
    MS-Off Ver
    2000
    Posts
    11
    Quote Originally Posted by jindon View Post
    Without seeing how you wrote it, no one can even guess what is going on.
    Thanks, I will attach the code here once back to office next week.

  15. #15
    Registered User
    Join Date
    06-07-2018
    Location
    singapore
    MS-Off Ver
    2000
    Posts
    11

    Re: if part of text is in red color then true

    hi,

    I'm back to office again.

    here is the simple macro i wrote, however the result is #name?. Pls help to advice what to do to fix it?

    Sub Macro1()
    '

    Dim LASTROW As Long

    LASTROW = Range("A" & Rows.Count).End(xlUp).Row

    Range("B5").Select
    ActiveCell.FormulaR1C1 = _
    "=(txtColor(RC[1],3))"

    Range("B5").Select
    Selection.AutoFill Destination:=Range("B5:B" & LASTROW)

    Range("A5").Select

    End Sub

    Function txtColor(r As Range, clrIndex As Long) As Boolean
    Dim i As Long
    Application.Volatile
    For i = 1 To Len(r.Value)
    If r.Characters(i, 1).Font.ColorIndex = clrIndex Then
    txtColor = True: Exit For
    End If
    Next
    End Function

  16. #16
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: if part of text is in red color then true

    1)
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    2) You said
    however the result is #name?.
    No, I can not replicate the issue.

    Upload a workbook.

  17. #17
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: if part of text is in red color then true

    did you enter the function under the sheet in the vba and not under an ordinary module?
    if so try moving the function to an ordinary module (eg module1)

+ 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. blue font color part of text in listbox
    By k1dr0ck in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-13-2017, 09:32 PM
  2. Text color for part of a string
    By adamsdr3 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-03-2015, 12:41 PM
  3. Return TRUE if 'part text' found in cell range
    By AnnieM in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 07-23-2014, 05:10 AM
  4. [SOLVED] Find Text In Range With Part Of Text & Return True or False
    By tis28 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-30-2013, 09:35 PM
  5. Check if part of text is in cell, add text if true
    By schorrie in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-16-2013, 11:21 PM
  6. how to find a color in a row where the color is blue , if true fill with a specific text
    By jayakumar.chandran in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-01-2012, 03:38 AM
  7. Applying font color to part of text
    By ballack in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-21-2007, 01:44 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