+ Reply to Thread
Results 1 to 9 of 9

VBA "vlookup" but keeping source formatting

  1. #1
    Forum Contributor
    Join Date
    02-03-2020
    Location
    Wisconsin
    MS-Off Ver
    365
    Posts
    150

    VBA "vlookup" but keeping source formatting

    As the title mentions, I'm trying to essentially do what a vlookup does. I have 2 sheets, each sheet contains the same values in column A - but not in any specific order. Here is what I am looking to do.

    On Sheet 1 - lookup value =A2, Lookup Range = Sheet 2, Return range is column C. But I want them essentially copied and pasted as values that keep the source formatting so I don't lose my background colors.

    Any help would be appreciated.

    Thanks.

  2. #2
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: VBA "vlookup" but keeping source formatting

    Hello. A question:

    > Are these source formats all the same or do the cells keep changing their formats?...
    You are always very welcome if you add reputation by clicking the * (bottom left) of each message that has helped you.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: VBA "vlookup" but keeping source formatting

    You don't say where you want the result pasted to. For this example I am using C2.
    Please Login or Register  to view this content.
    But I want them essentially copied and pasted as values that keep the source formatting
    This is contradictory. If you copy and paste as values you keep destination formatting. A normal copy & paste uses source formatting. Please clarify which one you want.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Forum Contributor
    Join Date
    02-03-2020
    Location
    Wisconsin
    MS-Off Ver
    365
    Posts
    150

    Re: VBA "vlookup" but keeping source formatting

    Beyond - they change. We use red, yellow, and green as sort of a "status tracker"

    6 string - apologies, I was thinking too much like it was a formula that I could put in the columns that I wanted. What you gave was helpful, but I should elaborate.

    The first part works well. Find matching value of A2 on WS1 in A:A on sheet2. Then, in that row copy value/format of C, and paste into Q2 on sheet1. Also the value/format of D from the row on sheet2, to R2 on sheet 1, and also the value/format of E on 2, pasted to S2 on 1.

    Then repeat for each row on sheet 1 - A3 on 1 would get data from C,D,E on sheet 2 ,pasted into Q,R,S back on 1 and loop all the way through until column A was blank.

    Sorry for the vagueness, still trying to learn some of this.

    Thanks in advance.

  5. #5
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: VBA "vlookup" but keeping source formatting

    Of course what you ask for can be done.

    Speaking of efficiency, this process will be between inefficient and very inefficient: Understood?...

    Please upload to the Forum a workbook that contains on one sheet some of your information and on another sheet show us what you want to obtain.

  6. #6
    Forum Contributor
    Join Date
    02-03-2020
    Location
    Wisconsin
    MS-Off Ver
    365
    Posts
    150

    Re: VBA "vlookup" but keeping source formatting

    Ive added a workbook, Please read the notes sheet first.

    Thank you.

    Also, the code that I've used in the past is extremely beginner level - basically just that which you can see from macros. So if there is anything complex about the vba, if you wouldn't mind giving a brief explanation regarding how it works so I can continue to learn it would be much appreciated.

    Thank you!
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: VBA "vlookup" but keeping source formatting


    Hi,

    so weird your expected result Sheet3 does not match Sheet1 & 2, so confusing …

    According to your explanation just try a beginner Excel basics like explained in VBA help : Range.Find and once found, use Range.Copy …

  8. #8
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: VBA "vlookup" but keeping source formatting

    I agree that your expected result sheet does not match the other data. But based on your description here is what you need. See attached. Click the button to run.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    02-03-2020
    Location
    Wisconsin
    MS-Off Ver
    365
    Posts
    150

    Re: VBA "vlookup" but keeping source formatting

    This sheet is used by multiple people. From the time I started, to the time that I created a version to attach - someone had gone in to adjust and I didn't catch it.

    But this code works perfectly. Thank you very much. I added rep.

+ 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. attempting to "change source" via "edit links"....
    By kouji804 in forum Excel General
    Replies: 0
    Last Post: 12-13-2022, 04:06 AM
  2. VBA Help - Keeping Source Data Formatting Using Vlookup for Multiple Cells
    By Meagan29 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-04-2019, 02:44 AM
  3. Replies: 7
    Last Post: 03-06-2019, 05:01 PM
  4. [SOLVED] Excel VBA Help: Keeping source formatting in VLOOKUP
    By Smores in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-06-2017, 05:31 PM
  5. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  6. Need VBA Code to "VLOOKUP" but keep source cell Formatting
    By flyyboy84 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-05-2012, 08:47 AM
  7. [SOLVED] Keeping Source Formatting with Paste Link and VLOOKUP
    By nrehman in forum Excel General
    Replies: 1
    Last Post: 10-06-2005, 02:05 PM

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