+ Reply to Thread
Results 1 to 5 of 5

Unable to configure Icon Set for a range

  1. #1
    Registered User
    Join Date
    08-23-2024
    Location
    UK
    MS-Off Ver
    Microsoft 365
    Posts
    3

    Unable to configure Icon Set for a range

    Good day!

    I am trying to set up conditional formatting on a range using icon sets.

    This should be achievable using the following steps:
    1. Obtain a reference to the FormatConditions property of the Range object
    2. Invoke the AddIconSetCondition method on the property to obtain a reference to an IconSetCondition
    3. Set the IconSet property of the IconSetCondition object to an IconSet of your choosing
    4. Obtain a reference to the IconSetCriteria collection of the IconSetCondition object
    5. For each member of the IconSetCriteria collection set the values of the following properties as desired: Operator, Type, Value (you may also set Icon)

    I am able to set the value of the Operator property, but when setting the values of either the Type or Value properties I get a 1004 Run-time error.

    It is somewhat frustrating because this should be possible according to the example on Microsoft Learn. I have even copied the example on Microsoft Learn into my module and attempted to run it - it also does not work with the same error.
    Here is the link to the example:

    Would anyone be able to offer a solution?

    P.S. Sorry, I've been disallowed from posting the link - just google learn.microsoft.com VBA IconCriterion for the example.

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,521

    Re: Unable to configure Icon Set for a range

    Remove this fragment:
    Please Login or Register  to view this content.
    Artik

  3. #3
    Registered User
    Join Date
    08-23-2024
    Location
    UK
    MS-Off Ver
    Microsoft 365
    Posts
    3

    Re: Unable to configure Icon Set for a range

    Hello Artik

    Did you run this code and did it work?
    For me a run-time error occurs when assigning a value to either Type or Value properties.
    I am using Microsoft 365 on Windows 11.

    Here is a copy of the code from Microsoft Learn, which can be pasted into a new xlsm file.

    Please Login or Register  to view this content.

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

    Re: Unable to configure Icon Set for a range

    As Artik said, you need to remove that first fragment. You don't set the bottom criteria - that depends on the other ones you have set (just as it does in the UI).
    Everyone who confuses correlation and causation ends up dead.

  5. #5
    Registered User
    Join Date
    08-23-2024
    Location
    UK
    MS-Off Ver
    Microsoft 365
    Posts
    3

    Re: Unable to configure Icon Set for a range

    Hi romperstomper

    Now I think I'm understanding: the IconCriteria element with the lowest index corresponds to the icon at the bottom of the list in the Edit Formatting Rule window, and the one with the highest index corresponds to the one at the top of the list.

    Hence, the properties of all IconCriteria elements should be set except for the first in the collection because it will be used implicitly if the criterion of the next one in the collection is not met - a bit like a default case in a switch statement.

    I will log on to my work computer later to try this out on the live code as opposed to just this example (which now works), and will confirm back later this weekend or next week.

    Thank you both.
    Last edited by AccidentalVbaAnalyst; 08-24-2024 at 09:22 AM. Reason: cosmetic

+ 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. Unable to configure Excel 2019 the way I used Excel 2010.
    By stlucia in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 10-10-2020, 05:42 PM
  2. Populate and configure List box (Userform) from a dynamic range of data.
    By thebeastslayer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-08-2020, 05:53 AM
  3. Unable to get Icon file when embedding a file in Excel
    By wilster98 in forum Excel General
    Replies: 1
    Last Post: 12-25-2017, 08:26 PM
  4. Replies: 6
    Last Post: 12-03-2014, 07:13 PM
  5. [SOLVED] How do I configure a scroll range that is permanent?
    By deldalton in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-04-2013, 11:49 AM
  6. Excel 2007 : Unable to delete Data Validaton Icon
    By Hatchiman in forum Excel General
    Replies: 2
    Last Post: 01-09-2011, 01:50 AM
  7. Unable to open a file from its icon in folder
    By John in forum Excel General
    Replies: 4
    Last Post: 02-13-2006, 10:10 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