+ Reply to Thread
Results 1 to 2 of 2

Find cell with identical value and copy it's background color

  1. #1
    Registered User
    Join Date
    07-14-2009
    Location
    London,England
    MS-Off Ver
    Excel 2003 and Excel 2007
    Posts
    17

    Find cell with identical value and copy it's background color

    Dear all

    I have two sets of data on a worksheet. One set of data is spread over the range A2:U14. The second set of data is written in the column X2:X40. 1 cell in the range has the identical text to 1 cell in the column.

    I am trying to create a macro that, when run, performs the following task:

    Finds the matching cell in the column X2:X40 and the cell in the Range A2:U14.

    Changes the formatting of the cell background in X2:X40 to the same background color to its corresponding cell in A2:U40.

    For example:

    Cell A9 has "John" written in it and a yellow background
    Cell X4 has "John" written in it and a clear background

    During macro:
    finds these two matching cells
    changes X4 so that it also has a yellow background

    After macro:
    Cell A9 has "John" written in it and a yellow background
    Cell X4 has "John" written in it and a yellow background

    Have been searching for answer but am still completely nowehre. Please can someone help me with the code?

    Thanks for your help

    Kind regards,
    Paul

  2. #2
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: Find cell with identical value and copy it's background color

    When you post problems like this it makes it much easier if you could provide a sample workbook with no sensitive data as it makes it easier to write the code otherwise the person trying to answer your question may have to create their own workbook to test the code. There is a discrepency in your post because you say
    Finds the matching cell in the column X2:X40 and the cell in the Range A2:U14.
    then you go on to say
    Changes the formatting of the cell background in X2:X40 to the same background color to its corresponding cell in A2:U40.
    I am not sure if the range should be A2:U40 or A2:U14 so you will need to change the code accordingly to match your workbook.
    Try this code - it should do what you need. Let me know if you have any problems - add the following code to a module and run matchVals
    NOTE - Change A2:U14 to A2:U40 if latter is correct. Make sure you run this on backup as you cannot undo VBA code. Also change Sheet1 to the name of the sheet with the data.
    Please Login or Register  to view this content.
    Last edited by smuzoen; 07-05-2012 at 10:23 AM.
    Hope this helps.
    Anthony
    Pack my box with five dozen liquor jugs
    PS: Remember to mark your questions as Solved once you are satisfied. Please rate the answer(s) by selecting the Star in the lower left next to the Triangle. It is appreciated?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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