How would you write VBA code to complete the following.
If any of the previous 2 cells were yellow then orange
If any of the previous 2 cells were orange then red
If any of the previous 5 cells were red then purple
If any of the previous 5 cells were purple then purple
Thanks in advance!
I appreciate your confidence in my ability, but VB code is new to me. I have never written anything in VB and do not know where to even begin. Any help here with the code itself would be appreciated.
Sorry Skip,
Let me start by saying I appreciate your help. By providing you this detailed analysis I found I was trying to build it incorrectly, thank you for that! This should clear up the confusion, if you have any follow-up questions please ask.
I attached sample data at...
OK, I will start with the beginning part. This is for a tardy policy at work. The cell will have entries from blank to 20 or so (the number of tardies that month for an individual) but the employee is given 2 freebies a month. No action is taken until 3 or more have accumulated. In addition...
I have the following code that I need to modify to count the cell only if it is 3 or above and the value of the cell would be value -2. Maybe some kind of lookup function with the following table?
0 0
1 0
2 0
3 1
4 2
5 3
6 4
This modified value would be for all cells in the offset. Then when...
I have the following code working perfectly, but need to add one thing. If the current cell is blank I want the select case code to be ignored. Can you help?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim oCell As Range
For Each oCell In Range("I10:Z22")
myTot =...
I figured it out, it was looking vertical verses horizontal, one line needed to be changed.
New Line
myTot = myTot + oCell.Offset(0, -i).Value
One final question, how do I make the color update upon data entry in the cell?
PHV, thanks for the help, your version worked, but I had to make some changes to the code and now I get a runtime 1004 error. Any ideas? Below is what I changed the code to.
Private Sub Worksheet_Calculate()
Dim oCell As Range
For Each oCell In Range("H2:Z22")
myTot = oCell.Value...
The code I found below works great except I need the case or lookup to be based on the sum of the active cell and the previous 5 cells. This is similar to the Formula Is function of traditional conditional formatting. How would this be incorporated to the code below?
Private Sub...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.