+ Reply to Thread
Results 1 to 4 of 4

UDF to make a double vlookup and change the cell background color

  1. #1
    Registered User
    Join Date
    05-12-2021
    Location
    México
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (16.0.13530.20054)
    Posts
    17

    UDF to make a double vlookup and change the cell background color

    Dear Community:

    I hope you all are having a wonderful day! Hope you could please help me to find a solution (if any)

    I have to do +500 analysis of locations, each location will have a independent sheet, with it's own elements and variable table length.

    Each sheet has:
    UPPER TABLES: all the upper tables have the same structure since they come from a pivot table (they are "official" tables, with name and all). These tables contain 3 main columns, Shape ID (Column D), a "Real" Name (Column E) and a ShortCode (Column F).
    All elements in Shape ID, and "Real" exist, but not all ShortCodes exists. Please see the image below.

    Proper_Table.png

    There is also a "manual table" below each "official table". This table was created manually relating Shape IDs from the "official table" above. This "manual" table also is consistent across all the +500 locations.

    What I need to do is:

    With a VLOOKUP, using SHAPE ID in column B from the "manual table", create a new "manual table" with the SHORTCODE. If the Shortcode does not exist, I need to do another vlookup and this time, bring the "real name" and highlight the cell with yellow. I've doing it manually and I got dizzy after location 50 hehehe.

    Is there a way to do a UDF to do both vlookups and the backgroud color change based on the result of the first lookup? It would be ideal if the UDF asks for the cell to evaluate as input. The "official" table to use could be defined by default as the only table that exist on each sheet and program the rest of the vlookups (it's always the same formula, its always the same "active table", its always the same columns, etc). Hope you can help me, please my soul is dying here.

    Attached is the sample file. With the final result.



    Thank you so much in advance! Have a nice weekend!
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by Magmarinita; 07-04-2022 at 01:37 AM.

  2. #2
    Registered User
    Join Date
    05-12-2021
    Location
    México
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (16.0.13530.20054)
    Posts
    17

    Re: UDF to make a double vlookup and change the cell background color

    Please see update below. Thanks!
    Last edited by Magmarinita; 07-04-2022 at 01:36 AM.

  3. #3
    Registered User
    Join Date
    05-12-2021
    Location
    México
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (16.0.13530.20054)
    Posts
    17

    Re: UDF to make a double vlookup and change the cell background color

    Hi!

    I already figure most of it out. Just the cell color part is failing. Could someone please help me? I need to change the color of the cell if the Short_len = 0. I commented it just to test if the rest is working and it does. The problem is in the commented line.

    Please Login or Register  to view this content.
    Could someone please help me to point me in the right direction?

  4. #4
    Registered User
    Join Date
    05-12-2021
    Location
    México
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (16.0.13530.20054)
    Posts
    17

    Re: UDF to make a double vlookup and change the cell background color

    I could not find a way to do it through a function, I think it is not possible due to the nature of the UDF. But I created a sub that helped me. It's a two step process but it's something. If anyone has some similar issue, I got this:
    Module 1 (perform a vlookup only if the middle table has an empty cell)
    Please Login or Register  to view this content.

    Module 2: Color the cells that were empty in the middle table for the final result.
    Please Login or Register  to view this content.
    Maybe there's a better way to do it but I really couldn't find it. Hope this can help someone in disgrace like me hehe
    Attached Files Attached Files
    Last edited by Magmarinita; 07-05-2022 at 09:52 PM.

+ 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. change background textbox color based on text color in cell
    By atadaliran in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-05-2021, 05:34 AM
  2. How to make the color fill background of a cell transparent (between 0 to 100%) in VBA?
    By Janna One Trick in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-03-2021, 05:42 PM
  3. Replies: 8
    Last Post: 04-02-2016, 04:00 AM
  4. Change a Range's cell background color to that of another cell's cond. format color
    By kamelkid2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-31-2014, 12:57 PM
  5. Change cell background color based on another cells background color
    By Queo in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 4
    Last Post: 06-10-2014, 05:28 AM
  6. Replies: 4
    Last Post: 07-09-2012, 04:32 AM
  7. [SOLVED] Macro to change all cells with a certain background color in another background color
    By kevinvzandvoort in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-13-2012, 11:04 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