+ Reply to Thread
Results 1 to 14 of 14

Change listItem forecolor based on criteria

  1. #1
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Change listItem forecolor based on criteria

    Hi
    I'm trying to adapt the code below to a listview in my userform.
    What I want to do is to change the item forecolor to red if text in "L" column fits criteria.
    Macro works but text color remains the default black.

    Please Login or Register  to view this content.
    Woulf you offer some help with this, please?
    Thanks in advance
    Ioncila

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Change listItem forecolor based on criteria

    you need to post example workbook as your code appears to work. I get a listview full of red text.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: Change listItem forecolor based on criteria

    Hi Thank you for the reply and sorry for the late.
    here is the attachement extracted from the original file. Hope it helps you to help me

    Thank you very much in advance
    ioncila
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: Change listItem forecolor based on criteria

    Any help, please?

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Change listItem forecolor based on criteria

    I thought I had replied

    Your workbook is referencing version 5 of the controls. I have version 6 and your code works with that.
    So it maybe version 5 does not support font colour of individual list items.

  6. #6
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: Change listItem forecolor based on criteria

    Hi
    Thanks for your feedback.

    I don't think that is the issue because in my original file Microsoft Windows Common Controls 6.0 (SP6) is active.
    In fact, I have same active libraries as in the file I have found this color option, here:
    http://www.vbaexpress.com/kb/getarticle.php?kb_id=916
    So it must be something in the code.

    Thanks in advance
    Ioncila

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Change listItem forecolor based on criteria

    As I said for me the code works. The list items are all red

  8. #8
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: Change listItem forecolor based on criteria

    Quote Originally Posted by Andy Pope View Post
    As I said for me the code works. The list items are all red
    Sorry for the insistance, but do you have red items with my code( attached file)?

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Change listItem forecolor based on criteria

    If I replace the listview control with the one from v6.0 controls then yes.

    Did you mean to attach a new file to your latest post?

  10. #10
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: Change listItem forecolor based on criteria

    Quote Originally Posted by Andy Pope View Post
    If I replace the listview control with the one from v6.0 controls then yes.

    Did you mean to attach a new file to your latest post?
    The attached file in post #3

  11. #11
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Change listItem forecolor based on criteria

    So if I change the control to use v6.0 then your code works as expected. It only adds 2 rows in to the control.

    I extended you code to add non matching items in as black.

    workbook includes screen shot of the userform
    Attached Files Attached Files

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,015

    Re: Change listItem forecolor based on criteria

    FYI you have references to both version 5 and version 6 of the Common Controls and the control you were using, as Andy said, is the v5 one. Change it to a v6 control and try again.
    Everyone who confuses correlation and causation ends up dead.

  13. #13
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: Change listItem forecolor based on criteria

    Andy
    Thank you very much for your time but I'm still in the dark for a solution.
    Your file returns "object required error", my file works but red items don't show up, libraries are exactly the same,...
    I'm going to look better for the files and try to see what is wrong.
    And, if so, prepare a clone of my original file to attach.

    Thanks
    Ioncila

  14. #14
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: Change listItem forecolor based on criteria

    Hi again
    I was misunderstanding the tip: when you said to change control version I thought you meant Microsoft Windows Common Controls 6.0. Now I know that you were talking about Listview Control version in additional controls. Sorry to get too much time to understand.
    So I tried in your attached file and it works.
    But in my original file, I still don't make progress in that way.
    I attach now a sample of my original file.
    Would you please point me some directions to the right solution?
    Thank you again in advance
    Ioncila
    Attached Files Attached Files
    Last edited by ioncila; 08-15-2012 at 09:35 AM.

  15. #15
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2013
    Posts
    137

    Re: Change listItem forecolor based on criteria

    Hi again
    I was misunderstanding the tip: when you said to change control version I thought you meant Microsoft Windows Common Controls 6.0. Now I know that you were talking about Listview Control version in additional controls. Sorry to get too much time to understand.
    So I tried in your attached file and it works.
    But in my original file, I still don't make progress in that way.
    I attach now a sample of my original file.
    Would you please point me some directions to the right solution?
    Thank you again in advance
    Ioncila
    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)

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