Results 1 to 6 of 6

Macro won't insert colors correctly

Threaded View

  1. #1
    Registered User
    Join Date
    07-31-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    6

    Question Macro won't insert colors correctly

    Hey everyone,

    I've written a Macro that Tries to control the coloring of certain cells in File "Y", by using certain values in File "X" that represent the months and quarter of the year.

    My problem is that even when the values in File X change, the colors in File Y are not changing correctly.

    Here's the code I've written so far:
    If Workbooks("File X.xlsm").Sheets(1).Range("B11").Value = 2 And Workbooks("File X.xlsm").Sheets(1).Range("B12").Value = 2 Or 5 Or 8 Or 11 Then Workbooks("File Y.xlsm").Sheets(6).Range("E19:J41").Interior.Color = RGB(51, 51, 51)
    If Workbooks("File X.xlsm").Sheets(1).Range("B11").Value = 2 And Workbooks("File X.xlsm").Sheets(1).Range("B12").Value = 2 Or 5 Or 8 Or 11 Then Workbooks("File Y.xlsm").Sheets(6).Range("I46:I48, I51:I54, I58:I59, I62:I68, I73:I75, I78:I81, I85:I86, I89:I95, I106:I108").Interior.Color = RGB(79, 129, 189)
    If Workbooks("File X.xlsm").Sheets(1).Range("B11").Value = 3 And Workbooks("File X.xlsm").Sheets(1).Range("B12").Value = 3 Or 6 Or 9 Or 12 Then Workbooks("File Y.xlsm").Sheets(6).Range("E19:J41, E46:J68").Interior.Color = RGB(51, 51, 51)
    If Workbooks("File X.xlsm").Sheets(1).Range("B11").Value = 1 And Workbooks("File X.xlsm").Sheets(1).Range("B12").Value = 1 Or 3 Or 5 Or 7 Then Workbooks("File Y.xlsm").Sheets(6).Range("E19:J41, E46:J68").Interior.Color = RGB(255, 255, 255)
    If Workbooks("File X.xlsm").Sheets(1).Range("B11").Value = 1 And Workbooks("File X.xlsm").Sheets(1).Range("B12").Value = 1 Or 3 Or 5 Or 7 Then Workbooks("File Y.xlsm").Sheets(6).Range("I19:I21, I24:I27, I31:I32, I35:I41, I46:I48, I51:I54, I58:I59, I62:I68, I73:I75, I78:I81, I85:I86, I89:I95, I106:I108").Interior.Color = RGB(79, 129, 189)
    If Workbooks("File X.xlsm").Sheets(1).Range("B11").Value = 3 And Workbooks("File X.xlsm").Sheets(1).Range("B12").Value = 3 Or 6 Or 9 Or 12 Then Workbooks("File Y.xlsm").Sheets(6).Range(" I73:I75, I78:I81, I85:I86, I89:I95, I106:I108").Interior.Color = RGB(79, 129, 189)
    Basically, I'm trying to grey out certain tables if there is a change in the month, but keep certain cells blue. I've written codes to try to replicate this coloring for the first month of the quarter, the second month of the quarter, and the 3rd month of the quarter.

    But the coloring isn't working. I'm also having similar problems with getting certain cells to lock depending on the month in the quarter. Is there a way to better control my conditions for "If, then"?

    Thanks, any help would be greatly appreciated,

    jning
    Last edited by Leith Ross; 08-02-2012 at 12:31 PM. Reason: Added Code Tags

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