I am trying to a macro that allows me to change the backgroud color and font color depending of the value of the cell.
For example is cell A1 is having the value between 1 to 3 the background color of the cell will the light turqoise, if the value is between 4 to 20 the cell background color will be green and so on.
I have based on certain posted example and adapt to my code but somehow it is not working.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
Select Case Target.Value
Case Is = 1, 2, 3
Target.Interior.ColorIndex = 34
Case Is = 4, 5, 10, 20
Target.Interior.ColorIndex = 43
Case Is = 30, 40, 50
This very simple color code below worked before but now it gives "Application-defined or object-defined error". When I try it on a new workbook, it works fine.
Code: Sub sdsdfsd() Selection.Interior.Color = 65535 End Sub
I have the following code to check the date of birth entered into cell C18 and to alert the inputter if the age is either under 16 or over 25.
VB: Sub AgeValidation() Dim age As Integer Dim dob As Range Dim AgeMsgAnswer16 As String Dim AgeMsgAnswer25 As String
[Code] .....
It works to some extent in that the correct message box pops up if the age is under 16 and similarly if over 25. If answering Yes on either message box then the correct thing happens. Its what happens if the inputter selects No thats not right. If the age is under 16 and the user selects No in answer to "Is this correct?" then the code is clearing the cell contents and showing the calendar again but is also popping up the 'Over 25' validation message box which then won't go away until Yes is selected. Also there are then multiple copies of the calendar open.
What I need the code to do is look at the date selected from a popup calendar in c18 and decide if that age is within the 16-25 year old range. If it is outside that then the inputter needs to be alerted to it. I can't use the inbuilt data validation because there are some scenarios where it would be acceptable to have an age outside of that range but we want to cover inputting errors as well as double checking the age.
When a msgbox pops up to alert the inputter and they choose "Yes" to say the date of birth is correct then I want the focus to go to cell C20 ready to input the next piece of information.
When the inputter selects "No" on the message box, then I want the original date to be deleted and the calendar to reappear so they can select another date. So effectively resetting the field so they can start again choosing a date like when they first entered the cell.
I would like to have a vba code that changes the cell color so that if there is number 1 (just number 1) in some cell the background of the cell changes in to shade of grey and cell that has number 2 changes into darker shade of grey and so on. I have numbers 1-10 in random order in my sheet. I mean there is many cells that has the same number and the sheet is quite large so vba code would be ideal choise to do it quickly.
How to "hard code" a cell's fill color? I want to assign a cell's fill color to yellow. While setting the fill color is easily done, my problem is that as soon as I paste data into that cell, it looses its fill color. Is there a way to tell the cell to never change the fill color?
VBA code in worksheet won't revert a changed cells color back to 0(white) after removing the comment.
Observations: code does set the desired cell colors to Yellow after inserting a comment, however removing said comment, and re-activating the worksheet does NOT reset the color after deactivating/re-activating the worksheet.
I have cells in range L12:BN1000 with formulas that will output a 1 or a 2.
If the output is 1, I would like the cell to color yellow if the output is 2, I would like the cell to color orange
the reason I dont want to use conditional formatting is because the use needs to be able to copy and insert rows and by doing so the use would need to manually add the new cells into the conditional format range. I would like to come up with a macro that applies this condition to a large range.
also, were do I add this macro? under sheet1? this workbook? or as a module?
I have an excel spreadsheet where column "D" will have one of fifteen different names inserted. According to which name is present, the cell needs to be a specific color. Any ideas on what would be the best code to use to read the entire column and format the cells that have names?
I have 16 columns (B:Q) Row 1 contains either a number, the letter x, or the letter a. Cells in Range("B2:Q628) contains either the letter x or is blank
If a cell in row 1 contains an x, then all cells in that column with an x has an Interior.ColorIndex of 45
If a cell in row 1 contains an a, then all cells in that column with a blank has an Interior.ColorIndex of 45
If a cell in row 1 contains has a number, then nothing
I have a table with rows and columns, to record status of various activities. One of these columns is to record when an update to a cell in the row has been made. I would like a macro that would, when the data in a cell has been changed, to highlight that cell in a different color and enter the date the change has been made, in the update column "Last Updated" for that activity. This way I can see what cells have been changed and when.
If I have a cell containing a formula say c1= sum(a1..a10) and the output appears in a50. how do I colour code it so I know the formula in c1 is linked to the output in a50?
In column "L" there is the possibility to have one of the following characters entered as a key for that specific row; G X B G1 G2 S Y H SB1 SB2 They all have a unique color assigned to them. There are too many for conditional formatting, so I think the way to resolve this is to use VBA. Can I ask for some assistance to get me started?
I have the code below set to change the background color based on certain conditions. What I need to do is change it so that if none of the conditions are met, it does not change the color at all. As it is written now, if anything is entered in a cell that has a background already set, but does not meet these conditions, the cell turns white.
I'm writing some VBA code for Excel. I need to change the color of a cell based upon the data in another cell. This selects sheet "Kane", and searches for the word "Expenses" in a range in column D. Using For-Each, I need the IF statement that will change the cell color in the same row, but in column P.
I have previously used the following code to successfully pull out IE webpage source code for string manipulation.
Its a crude example to demonstrate the principle:
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Public IE As Object Sub Sample() Set IE = CreateObject("InternetExplorer.Application") IE.Visible = True
[Code] ......
However when I substitute in a Google websites address into the IE.Navigate command, the code runs to the "Source_Code = IE.document ...." line then flags up a Microsoft Visual Basic error. "Run-time error '438': Object doesn't support this property or method"
The webpage that I am trying to access is a confidential company site, so you won't be able to access it yourself, but starts with [URL] ......
The one thing that I have noticed about this website is the Privacy Report icon in the lower right status window (Picture of an eye with a restricted symbol in front). I don't know whether this is the cause of my problem, or purely an incidental observation.
Is there something peculiar with Google sites that means that the source code cannot be extracted in general, or is this an issue specific to my site ? Does the Privacy Report icon have any relevance, and if so how do I switch that off ?
I have a spreadsheet that will contain about 5-15 rows with a letter "S" in the column. If this letter S appears in the column, I need its entire row to change font color to RED and then change that row's value in column L to a negative number. is there any easy way to do this?
Is there a way to create a macro to color code a cell based on the value in a cell, and then look up a value in a table, then color code it based on where it fits into the table?
I have a table of values for about 30 projects. In column g - there is a CPI value (see bold column)
Example: Project ID Name Program PMT SI ID AC Milestone TCP Level [Code] ......
Here is the table:
I have to color code a cell, base on the CPI and how it fits into the table below. So if the current Milestone is M2 or M3 and the CPI calculated is .14 the cell would be colored RED, if the CPI number is 2.01 for M2-M3 I would want cell to be colored Turquiose. If we were at Milestone M6 and the CPI was 2.01, it would be colored blue. If the CPI was .75 at Milestone M5, it would be colored Green
If input is entered into column C (range C2:C100), then row cells for columns D, E ,F, H or I must NOT be blank upon save. Could be that one or more of these row cells are left blank by mistake.
An error msg pops up upon attempting to save, stops the save and colors each cell yellow that needs info entered into.
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
Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Me.Range("E:N")) Is Nothing Then If Range("E34").Value = 0 Then Application.EnableEvents = False Range("G8").Value = Range("G8").Value + 1 If Range("J34").Value = 0 Then Application.EnableEvents = False Range("G9").Value = Range("G9").Value + 1 Application.EnableEvents = True End If End If End If End Sub
Every time I try to add the contents from the request form to the Master CCO tab, the information does not dump. The only way the form will close is if i hit the cancel button. I don't know what I've done wrong with the add request code.
I got this code off here and it works really well on my home pc which is using widows 2000 however i need it for work and they are using windows 97.
I get an error with the code in red. I have attached the sheets this refers to, and when i run the code it deletes the dates it matches up with in the master rota sheet which it shouldn't
Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False If IsNumeric(Target.Value) Then 'Clear the Invalid entry Range("L4").ClearContents Range("L5").ClearContents
If Target.Address = "$K$4" Then Range("K5").ClearContents ElseIf Target.Address = "$K$5" Then Range("K4").ClearContents End If Else Range(Target.Address).ClearContents Target.Next = "Invalid Input" End If..........
However for L28, L29, L48, and L49 the invalid input entry is not showing up properly.
I am trying to add code to a module that is already working. however when trying to add new code i keep on getting error messages. It doesnt like the "next i" see attachment.
all else works except for the WEEK1 tab. I am trying to get it so if the "Date Submitted" colum on the MAIN tab is between 5/3/09 - 5/9/09 it will go to tab "WEEK1"
5/10/09 - 5/16/09 to WEEK2 5/17/09 - 5/23/09 to WEEK3 5/24/09 - 5/30/09 to WEEK4
There is only one sheet in this workbook, the sheet name changes each time I run other codes. I am bringing the value of the sheet name into a H1 cell and trying to save with that name.