Macro: Changing Cell Color Based On Date In Cell

Jan 12, 2009

I did a search on this site and found some code I was looking for (see link:

http://www.excelforum.com/excel-prog...e-in-cell.html - Leith Ross's response code).

The code works perfectly, however, if I save the workbook with a different spreadsheet on top than the spreadsheet referred to in this code, I get an error message: Method 'Range' of object '_Worksheet' failed.

I should state that I did change "Private Sub Workbook_Open()" to "Private Sub Auto_Open()".

I assume I need to modify the code but am unsure as to how.

View 11 Replies


ADVERTISEMENT

Changing Font Color Based On Date Value In Another Cell

Mar 7, 2014

i have had to change the quarters that our company works in and in doing so have to make some changes to my VBA code. our quarters have moved back 1 month so Q1 = Dec/Jan Feb now.

below is a copy of the code that used to make the associated cell font color red depending on the current date. i need to change it to be relevant to the new quarter structure.

[Code] .....

As you can see if the month value is less than 4 (jan/feb/march) it will highlight red....however i dont know how to change the range to specifiy the ranges 12,1,2 as per the new quarter structure.

View 2 Replies View Related

Changing Cell Color Based On Changing Values

Sep 16, 2009

This may have been answered on here but can not seem to find it. My situation is I have values in A1,A2 & A3 that are like counter reading so the value is always changing. What I am looking to do is change the cell color if one of the values is over 500 from the other two values. Say A1 is 3000, A2 is 3250 and A3 is 3500. I would like the cell for A3 to change color.

View 2 Replies View Related

Changing Cell Background Color In Another Sheet Based On Cell Value

Jun 13, 2013

I am working on a workbook with 200+ sheets and an index linking to each of the sheets. On the sheets there is a cell containing the results of calculations and I need the cell referencing the sheet in the index to change background colors depending if the calculations value is greater or less than 0. I currently have working code that also changes the tab color of each sheet depending on the value, but i am trying to add the index cell background change functionality into that. also, the index listings is subject to change. my working code is

VB:

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("d34").Value < 0 Then
Me.Tab.ColorIndex = 3
ElseIf Range("D34").Value > 0 Then
Me.Tab.ColorIndex = 4
Else

[Code]...

and the code i am trying to get working is

VB:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngX As Range
Set myRange = Worksheets("Index").Range("A1:A500").Find(Range("C2").Text, lookat:=xlPart)
' the C2 is the reference the title that would be on the index
If Range("d40").Value < 0 Then

[Code]....

I keep getting the runtime error '1004: application-defined error or object-defined error the thing is, i ran the cell background changing code in a normal macro before integrating it in my other worksheet code first and it worked fine. I have a little code experience, though not much in vba and I am unsure what the issue is. if there is another better way to accomplish what I'm tring to do, that would also be fine.

View 4 Replies View Related

Changing Color Of Cell By Date

Mar 2, 2009

I am trying to make a reference to tell me when my rigging gear is due for inspection. I want the cell to change colors when a date is in range. For example i would like a red cell when the item is due or past due for inspection. A yellow cell for when the item is 90 days out from the due date. i have used conditional formating and used =E$-30<=TODAY() and changed cell to red. but when i add another format, for E$-90<=TODAY() for yellow, it will not work.

Once this is solved, i will need to make the entire row change color.

View 12 Replies View Related

Changing Color Of Cell By Date

Dec 29, 2008

what I want can be done in the 'Conditional Formatting' but I can't seem to figure it out.

I have a spreadsheet with specific dates down the left colum and I need that row to highlight when the date comes, and then return back to normal when the next date comes around and gets highlighted.

so for example, A1 = 1/1/2008 I need that row highlighted when 1/1/2008 comes around, then the next date would be A2 = 1/15/2008 and so on..

View 9 Replies View Related

Changing Cell Color Based On Value

Dec 30, 2009

Quick question, I know how to change a cells background / text color based on it's own value using conditional formatting but what would be the formula to change cell A1's background color based on the value of cell C1?

View 6 Replies View Related

Changing Cell Color Based On Cell Name

Feb 11, 2010

I have a work sheet with over 500 different name enteries. I need to change the cell color to red if the cell has the name "john" in it. The names are listed in a column (ex. A1:A500)

The cell could have the name "John Jackson", "John Johnson", "John A", or just "John". As long as the name "John" is found, the cell color should turn red.

If the cell has the name "Mike", "Mike A", "Mike Johnson" then change color to Green. Here I am looking for any cell that has the name Mike in it.

and so on ...

I have over 500 different names so Conditional formating won't help me here. I was wondering if I could do this with VBA coding.

View 9 Replies View Related

Changing Color Of A Cell Based On A Legend

May 10, 2007

I think looking at the attachment might make more sense, but here is a brief description of what I want to do. I am trying to change the colour of a cell based on looking up the value contained in that cell in a predefined list (which in my example I have called a legend). I need to do this in VBa but my VBA is not at all good.

View 4 Replies View Related

Changing Text Color Based On Information In The Cell?

Nov 28, 2013

I have created a gradebook template so that I can keep track of my assignments as I get them and keep on top of my grades. Any way that I can code excel to work so that if my current average in the class ever drops below 70%, I want the color of the text to change to red to alert me that the grade is too low and needs to come up. I'm new to using VBA in excel and not sure how to do it or what to code.

View 8 Replies View Related

Excel 2010 :: Changing Tab Color Based On Cell Value?

Mar 6, 2014

I am using Excel 2010 and trying to change/edit the color of the tabs in my workbook to turn green or red based on a y or n placed in a cell (the same cell on each tab). I have tried variations on several themes others have asked about as well for Excel 2007 and attempted to adapt them to fit my situation but none seem to work. Here's what I was starting with:

Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Range("A1").Value
Case Is < 2.5
Sheet1.Tab.Color = vbRed
Case Is > 2. 5, Is < 4
Sheet1.Tab.Color = vbGreen
End Select
End Sub

The cell I'm using is F2 and my cell value is simply y or n. I realize the example above references numeric values and greater than/less than options, but I'm not sure how to correct this for my need.

View 10 Replies View Related

Macro: Changing Color Of Coloumn Header Based On Rows Color

Jan 15, 2009

I wrote a macro to color the cell values in the rows based on their average value. For eg if the cell value is less than 0.2 Avg, they should be red color,if value is between 0.2 and 0.5 it should be yellow. This part is working fine

Now based on the color of the rows cells , need to write a macro for the header one. Logic is Coloum header should be in red colour, if in one or more number of rows cells are red. same with yellow ones. Could you please help me out in solving this with logic.

View 8 Replies View Related

Gantt Chart - Changing Cell Color Based On % Completed

Aug 12, 2014

I'm trying to create a simplified Gantt chart of sorts, and cannot figure out one piece of it. I'm not sure how to write out exactly what I need, but here goes.

I would like to have a formula that looks at the percent completed (which the user inputs) and multiplies it by the total duration for the task to give a total number of days completed. Then, under the corresponding dates, the color of the cell would change. I've attached a simplified version of what I'm talking about.

On the attached spreadsheet, the total duration (D2) is 5 days and the percent completed (C2) is 40%. This calculates to 2 days. With that said, I would like the cells under the first 2 days under the listed dates (E2 and F2) to change color. When the percentage complete reaches 60%, then G2 would change color, when it reaches 80%, then H2 would change, and when it reaches 100%, then I2 would change.

My guess is that the formula will need to result in a particular value, and then I'll use Conditional Formatting to do the actual changing of the cell color. Assuming this is correct, I still don't know what formula to use to accomplish this.

View 7 Replies View Related

Changing Fill Color Of Autoshapes Based On Cell Numeric Values

Jun 10, 2006

how I can change the color of an autoshape based on a value in a cell?

View 4 Replies View Related

Changing Cell Text Color WITHOUT Using Conditional Formatting Based On Finding Keywords

May 29, 2012

I have a spreadsheet that uses VB macros to calculate sums of cells based on the font color of the numbers inside. It used to be fairly easy going through each cell and "classifying" them by color, so that my macros can go ahead and sum the numbers in each respective color's cell... but now I have a huge amount of numbers and would like to automate the process somewhat. Here's an example using the A and B columns:

flight $400
hotel $150
hotel $130
meal $20
meal $15
flight $350

I tried using conditional formatting to automatically change the color of the adjacent cells based on the presence of a keyword such as "flight" or "hotel", but this change is only cosmetic, and doesn't actually change the font color (it is still the default black, hence why my color-summing macros won't work!).

I'm including a sample macro for what I use to color-sum my cells, but what I am looking to automate the color-coding process based on looking for keywords as explained above in my example. Here is one of the working color-summing macros (for red, in this case) if you'd like to use it as a reference:

Function SumRed(SelectedCells As Range)
' Adds the values of the cells where the font colour is red(3).
Dim Cell As Object
Dim x As Double

[Code] ...........

View 9 Replies View Related

Conditional Formatting - Change Cell Color Based On Date In Another Cell

Oct 9, 2013

I have two columns. In column B is the date of "last check". I column A is the date of "next check". I would like to have cell A2 in yellow color 334 days after the date entered in cell A3 and than in red color 365 days after the date entered in cell A3. Same thing for cell B2 related to date entered in cell B3. Yellow color in cells announces that check will expire within 30 days and red color that check has been expired.

View 1 Replies View Related

Changing Font Color Linked To Date Key Through Macro?

Aug 19, 2014

I am looking to change the color of my text through a macro, which is fine. But I want to change the color according to a date key. So every time I update my date once a week, a new series is "blacked in". The series has the link already in it, I just need it to change color (to black) every time I update it.

View 1 Replies View Related

Excel 2007 :: Changing Bar Series Color To Adjacent Cell Font Color

Aug 8, 2012

I am trying to use VBA in Excel 2007 to change bar chart series colors. I have found a few posts that link it to a cell background, but I'm struggling to find one that does the font color.

It would be great if I could change the bar chart series to match the color of the text in the A column, so that if I highlighted the value in A1 and changed the text color to orange for whatever reason, the chart updates the value of 1.2 to an orange bar (see below).

T. A1 B1

Sample 1 1.2

Sample 2 2.1

Sample 3 1.7

Sample 4 5.6

View 3 Replies View Related

Auto Send Email Based On Changing Date In Cell

Nov 20, 2008

I need to send an email reminder to teachers on the day they have duty. I know how to set up an email that sends on a certain date, but I am unsure how to code it when the date changes. I have attached the spreadsheet.

In cell A 53, I have the date November 24th. In cell C53, I have the email address of the teacher doing duty that day. In cell F53, I have the date November 25th. In cell, I53 I have the email address of the teacher performing duty that day. On November 24th, the person in C53 should receive a reminder email. On November 25th, the person in cell I53 should receive a reminder email. I will have spreadsheet for every month of the year. So there will be LOTS of changing dates. How do I code this when the date keeps changing?

View 2 Replies View Related

Change Tab Color Based On Cell Date

Oct 1, 2011

How to Change The Tab Color Based On A Cell Date ( Thursday & Friday ) Green Color, Rest of the week blue.

View 2 Replies View Related

Change Color Of Cell Based On Date

Jun 26, 2007

In an excell worksheet I need to change the color of a cell within a column based on the date entered. For example, if the date in the cell is 60 days from today's date then the cell should be green, if the date in the cell is 90 days from today's then the cell should be blue, if the date in the cell is 120 days from today's date then the cell should be yello.

View 9 Replies View Related

Shade Cell Certain Color Based On 1 Date Every Year?

Aug 6, 2013

I have a column with dates of July 1 of every year. How can I use conditional formatting to shade a cell a certain color based on July 1 of every year? The cell for July 2013 should be shaded, when 2014 comes, it is no longer shaded, then 2014 becomes shaded, & so on...

View 1 Replies View Related

Highlight Or Change The Color Of A Cell Based On The Date

May 10, 2007

I looked around at some date functions and could not find one to work.

I have a sheet that has 365 days. When I load the sheet I want to cell for today to be highlighted in some way..... color or just active.

If date = 05-10-2007 then
BackgroundColor = 17
else
BackgroundColor = 9
end if

View 9 Replies View Related

Excel 2010 :: Changing Cell Color And Border By Clicking A Cell

Apr 25, 2014

I would like to accomplish 2 things in my Excel 2010 spreadsheet by click a cell which already has a number and formatting in it.

1. How do I change the color of the cell, the color of the number in it, and the border around it. (Make it look like I just pressed a button by clicking it.)

2. At the same time have the text in different cell and the number in the selected cell appear in another different cell. (Text in a different cell = A , and the number in the selected cell = 23, the value in the resulting cell be "A 23") Everything I would like to happen at the same time by clicking the selected cell. I would also like this to be done several times by clicking different cells and not changing the previously selected cells.

View 1 Replies View Related

Changing Empty Cell Background Color Depending On Different Cell Value

Aug 7, 2014

I'm trying to create a tag with a color border. What I desire is to fill the BLANK cells around the tag, A1:D1 + D1:D19 + A1:D19 + A1:19 in a certain color based on the text value of the cell B11. There are 5 different values, such that if the B11 read Red Sox - the boarder is going to be red, if it reads Houston Astros it will be dark blue, etc..

I have a similar problem with changing the color of the cell based on the month. So regardless of the year, 2014, 2015, 2016, etc... If I use MONTH() function I can just get numbers from 1-12. I want Cell C16-C18 to be certain color depending the date entered in cell C17 such that for each quarter, months 1-3, 4-6, 7-9, 10-12 they are different color.

I have had no luck with conditional formatting (and I also believe that it is good up to 3 cases only). I am decent in logic/programming language but have little knowledge with macro notation and especially how to run them in excel 2013. I do know how to start it alt+F11 and that I need to make sure that code is written under the specific sheet where my tag is located.

View 6 Replies View Related

Macro That Calculates Sum Based On Cell Color?

Mar 28, 2012

The Excel file is in this link

[URL]

If you look at the chart on the left, it breaks down how this whole thing works. It takes the sum of the numbers that fall within each line. I wrote it out on column M so that it's more clear. In column D-L, I filled in random numbers ranging from 4000-700. The numbers in those gray boxes are ignored. This Macro should only apply to Column M and beyond. Is it possible to write a macro that will be able to do this?

View 1 Replies View Related

Conditional Formatting - Cell Color Based On Range Of Cell Color

Aug 9, 2013

Summary of performance of various products against target is as follows,

Product vs Target
Color Code
Result

CH4OH
Green
1.0

[Code] ........

I need the final result automated as follows,

If 2 green of the 4 products, then final result Gree
If 2 Amber of the 4 products, then final result amber
If 2 Red of the 4 products, final result Red

Is there a way to automate this?

View 8 Replies View Related

VBA Changing Color Of A Cell Using Clicking On Another Cell

Mar 4, 2010

i want to click or roll over a cell with the mouse, to change the color of another cell, or another multi cells.

another question.
Is it possible to change the color of a pic i put in the excel using a function or VB.

View 9 Replies View Related

Macro Delete Row Based On Color And Adjacent Cell?

Mar 28, 2014

i am looking macro formula to delete row with 2 criteria :

- delete rows if yellow color background and based on adjacent cell (blank cell), otherwise keep rows when adjacent cell not blank

View 8 Replies View Related

Changing Cell Color?

Mar 26, 2009

I have a code that check the String on the cell! But if it is wrong i wanna make the cell Red colored?

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved