+ Reply to Thread
Results 1 to 7 of 7

HLookup w/ Source Formatting Preserved

  1. #1
    Registered User
    Join Date
    09-20-2018
    Location
    Ottawa
    MS-Off Ver
    2013
    Posts
    5

    HLookup w/ Source Formatting Preserved

    Hello,

    I am working on a project which requires me to use the HLookup function to reference data from Sheet 1 and transfer it into Sheet 2. The data in Sheet 1 is color coded and the cells have a color fill on them according to certain criteria. I am looking to preserve this information after the HLookup is executed and want the information in Sheet 2 to have the same formatting. Unfortunately, I cannot use conditional formatting on this job.

    Any help would be appreciated, and I don't mind Macros or VBA as long as the instructions are straight forward. If you know of another function that can achieve this functionality, I don't mind exploring that path either. I have attached a simplified version of my sheet to this thread.

    Thanks!

    Hello All, thanks for your help. I was able to use the code provided in the link below. The code doesn't do Vlookup, but I was able to get around that by using a match function nested in the Vlookup.

    [www] .mrexcel [dot com]/forum/excel-questions/554340-can-vba-vlookup-keep-cell-formatting-3.html
    Attached Files Attached Files
    Last edited by excelgod123; 09-25-2018 at 07:27 AM. Reason: solved

  2. #2
    Valued Forum Contributor
    Join Date
    07-14-2017
    Location
    Poland
    MS-Off Ver
    Office 2010
    Posts
    528

    Re: HLookup w/ Source Formatting Preserved

    Hi, if you can not use conditional formatting, only VBA remains.
    Please Login or Register  to view this content.
    Does my offer meet the expected results?
    Regards.
    Attached Files Attached Files

  3. #3
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: HLookup w/ Source Formatting Preserved

    Hi. I think you'll need to use some code to do this; you can't copy formatting with normal worksheet functions. Try this sample code:

    Please Login or Register  to view this content.
    WBD
    Office 365 on Windows 11, looking for rep!

  4. #4
    Registered User
    Join Date
    09-20-2018
    Location
    Ottawa
    MS-Off Ver
    2013
    Posts
    5

    Re: HLookup w/ Source Formatting Preserved

    Thanks for your reply. I was hoping to have some sort of a formula/function similar to HLookup, and not have it hard-coded for a specific range. This is because my range is dynamic and changes often.

    Cheers!

  5. #5
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: HLookup w/ Source Formatting Preserved

    Functions are not allowed to change the format of a cell. You'll need some logic to work out the ranges in question and use them in either of the examples above.

    WBD

  6. #6
    Registered User
    Join Date
    09-20-2018
    Location
    Ottawa
    MS-Off Ver
    2013
    Posts
    5

    Re: HLookup w/ Source Formatting Preserved

    Hello,

    I would like to have a dynamic range for my cell selections cuz it changes everyday. Your code has a preset range which I have to select, and that wouldn't be adequate for my situation. Please let me know if you know another way to do this.

    Thanks!

  7. #7
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: HLookup w/ Source Formatting Preserved

    You're not giving much away. "Dynamic Range" doesn't tell me where the range starts and how you can determine where it ends. For example, this will stretch the lookup values to the right from E2:

    Please Login or Register  to view this content.
    WBD

+ 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. Formatting not preserved INDEX - MATCH
    By melvinkoshy in forum Excel General
    Replies: 2
    Last Post: 12-07-2017, 11:49 AM
  2. [SOLVED] Hlookup for multiple values in source table
    By Sunil Dushila in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-05-2015, 05:48 PM
  3. refreshed excel doc with preserved formulas?
    By amc8468 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-11-2014, 06:10 PM
  4. Excel 2010 pivot table formatting not preserved after update
    By MARKSTRO in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 12-30-2013, 01:37 PM
  5. Formatting not preserved in web query Excel 2007
    By Methodician in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-05-2013, 01:36 PM
  6. how to force HLOOKUP to give output in the same format as the source table?
    By yessuz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-25-2013, 10:23 AM
  7. Replies: 5
    Last Post: 07-29-2012, 04:42 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