+ Reply to Thread
Results 1 to 6 of 6

Duplicating a Colour in a different sheet

  1. #1
    Registered User
    Join Date
    12-21-2009
    Location
    Brighton, England
    MS-Off Ver
    Excel 2003
    Posts
    3

    Lightbulb Duplicating a Colour in a different sheet

    Hi Guys!

    I was wondering if you could help me out with a little problem i'm having with Excel.

    I have two sheets. One contains two columns; hotel name and rating. The rating is a percentage and if the percantage is less than 30% the row turns red, 31 - 70% is yellow and 71%+ is green.

    The second sheet has lots of columns, they include the same hotel name column as in the first sheet but not the rating column. The sheet has thousands of rows and each hotel name may be duplicated lots of times but with different data in the other columns.

    I would like some way of taking the name from the hotel name column of the first sheet, seeing what colour it is and then excel automatically making any row which contains the same hotel name the same colour as it is in the first sheet.

    For example: Sheet 1 =

    Hilton Hotel, 90% (the row is green)
    Poor Hotel, 20% (the row is red)

    Sheet 2 =

    Hilton Hotel, 2 nights, Breakfast included (row automatically turns green)
    Hilton Hotel, 1 night, Breakfast included (row automatically turns green)
    Poor Hotel, 2 nights, Room Only (row automatically turns red red)
    Hilton Hotel, 7 nights, Room Only (row automatically turns green)

    I hope that what I am asking is possible and that somebody can help.

    Thank you for taking the time to read this post and I look forward to a solution!

    Matt

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Duplicating a Colour in a different sheet

    Hello Matt,

    Welcome to the Forum!

    You didn't say if your workbook has any formulas or conditional formatting in place. To provide you with a solution, It would be helpful to see the layout. Can you post the workbook? You will need to either remove or change any confidential information before you post it.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    12-21-2009
    Location
    Brighton, England
    MS-Off Ver
    Excel 2003
    Posts
    3

    Lightbulb Re: Duplicating a Colour in a different sheet

    Hi Leith,

    Thank you for your reply and the welcome!

    Unfortunately if I remove any confidential information, I would be removing everything!

    There are no formulae or conditional formatting in place. I actually have two seperate workbooks, rather than two separate sheets. This is because the first workbook/sheet is constant whereas I am send a new list of hotels on a weekly basis.

    Currently I am making each row red, yellow or green manually on the first sheet/workbook. I was going to try to figure out how to do that automatically myself as I can't see it being tooo difficult.

    I will try to explain the fields on the spreadsheets:

    First Workbook:
    Hotel Name | Percentage

    Second Workbook:

    Hotel Name | Star Rating | Location | Twin Price | Stay From | Stay Until | Breakfast

    On the first spreadsheet is simply a list of hotel names and Trip Advisor ratings.

    On the second spreadsheet is a list of hotel names and the details of offers we are doing for the current week. The same hotel name can appear multiple times on the second sheet and I forget which hotels are good and which are not, so im hoping that I can automatically colour code them based on their Percentage on the first spreadsheet.

    I'm sorry I can't post the workbooks. If you can't help without them then I understand, i'm just not able to upload them without breaching my companies security policies.

    Thanks again,

    Matt

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Duplicating a Colour in a different sheet

    Hello Matt,

    Sorry for the late reply. My ISP was down for about 9 hours today. I create 2 example workbooks based on your information. A macro is attached to the button on "Sheet1" of "Weekly Book 2". This colors the hotels based on the percentages taken from "Master Book 1". The names of the workbooks, and worksheets can be changed to what you are using. This is just an example so we can get moving in the right direction.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    12-21-2009
    Location
    Brighton, England
    MS-Off Ver
    Excel 2003
    Posts
    3

    Lightbulb Re: Duplicating a Colour in a different sheet

    Hi Leith,

    Thank you so muh for all of your hard work. The macro is exactly what I was looking for.

    I am having some difficulty in getting it to work for my workbooks though.

    My "Master Book 1" is "HotelsLondon" and the sheets within this book are "3 Star", "4 Star" and "5 Star"

    My "Weekly Book 2" can be changed to whatever name is required i.e. "HotelsList1".

    Do I need to put the code in "HotelsList1" or in "HotelsLondon"?

    I have tried both but get "Run-time error '9' Subscript out of range" even when I have changed "Master Book 1.xls" to "HotelsLondon.xls"

    Also is it possible for the "Weekly Book" to automatically color code without pressing a button?

    Again, thank you so much for your help!

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Duplicating a Colour in a different sheet

    Hello Dianbao,

    I'm assuming from this statement:
    My "Master Book 1" is "HotelsLondon" and the sheets within this book are "3 Star", "4 Star" and "5 Star"
    That all these sheets need to be checked for names and not just the first sheet in the "HotelsLondon" workbook.

    To make the macro run automatically when the workbook is opened, copy the code below into the "weekly" workbook and follow the instructions to install it.
    Please Login or Register  to view this content.
    How to Save a Workbook Event Macro
    1. Copy the macro using CTRL+C keys.
    2. Open your Workbook and Right Click on any Worksheet's Name Tab
    3. Left Click on View Code in the pop up menu.
    4. Press ALT+F11 keys to open the Visual Basic Editor.
    5. Press CTRL+R keys to shift the focus to the Project Explorer Window
    6. Press the Down Arrow Key until ThisWorkbook is highlighted in blue.
    7. Press the Enter key to move the cursor to the Code Window
    8. Paste the macro code using CTRL+V
    9. Save the macro in your Workbook using CTRL+S

+ 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