+ Reply to Thread
Results 1 to 7 of 7

How to color range based on XLOOKUP

  1. #1
    Registered User
    Join Date
    11-15-2016
    Location
    cairo, Egypt
    MS-Off Ver
    2016
    Posts
    5

    How to color range based on XLOOKUP

    Hello everyone,

    i need some help with vba because i dont know much about it.

    I have a large data range (50x 50 cells). I am using the XLOOKUP to find the average and Stdev of a range within that data. I also used XLOOKUP and CELL function to find the first and last cell of my range.

    Can anyone help me with a vba code that can automatically select that range and change the color of the range cells?

    i would like to use this vba code on all my sheets, not just one.

    here is the XLOOKUP function i am using in case it helpfull:
    =(XLOOKUP(AH59,A1:A50,XLOOKUP(AH62,B51:AY51,B1:AY50,"not Found",-1,1),"Not Found",-1,1)):(XLOOKUP(AH60,A1:A50,XLOOKUP(AH63,B51:AY51,B1:AY50,"not Found",-1,1),"Not Found",1,1))

    Thank you for the help!
    Attached Files Attached Files
    Last edited by Ksenofon111; 09-19-2021 at 11:20 AM. Reason: Solved! Thanks Everyone for your help!

  2. #2
    Forum Contributor
    Join Date
    08-12-2020
    Location
    Atlanta, Georgia
    MS-Off Ver
    Office 16
    Posts
    241

    Re: How to color range based on XLOOKUP

    Can you post your worksheet? It might be possible to achieve this with conditional formatting.

    Squeaky.

  3. #3
    Registered User
    Join Date
    11-15-2016
    Location
    cairo, Egypt
    MS-Off Ver
    2016
    Posts
    5

    Re: How to color range based on XLOOKUP

    Hi Squeaky,

    i have attached an example file to my original post.

    thank you

  4. #4
    Registered User
    Join Date
    11-15-2016
    Location
    cairo, Egypt
    MS-Off Ver
    2016
    Posts
    5

    Re: How to color range based on XLOOKUP

    I wrote a quick program(?) to do this but it takes forever to complete, very inefficient

    Please Login or Register  to view this content.
    each range is 2500 cells, total is like 12.5E+06 comparisons.

    there must be another way to do this.
    Last edited by AliGW; 09-18-2021 at 12:46 PM.

  5. #5
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,583

    Re: How to color range based on XLOOKUP

    Macro code.
    Conditional formatting is to be removed to color cells
    Please Login or Register  to view this content.
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: How to color range based on XLOOKUP

    For starters here's 1 that does it in 6.9sec.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,647

    Re: How to color range based on XLOOKUP

    @Ksenofon111

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. 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, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, 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

    (Note: this change is not optional. As you are new, I have done it for you today.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ 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] XLOOKUP to return cell based on multiple criteria in single column
    By mikehay08 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-24-2021, 02:59 PM
  2. [SOLVED] Mutil-critieria XLookUp with range is concacted together - not working
    By stearno in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-08-2020, 06:29 AM
  3. Name Range Based on Cell Color
    By conwaythibodeaux in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-18-2019, 05:38 PM
  4. [SOLVED] Color table row range based on row value
    By 7absinth in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 06-07-2017, 09:33 AM
  5. [SOLVED] change fill color of a range of cells based on color of a cell?
    By DarMelNel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-20-2014, 04:48 PM
  6. Setting Color of Range based on adjacent cell color
    By JimE in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-02-2009, 09:04 PM
  7. Color Range Based On Number Range
    By ajocius in forum Excel General
    Replies: 1
    Last Post: 11-24-2006, 12:49 AM

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