Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have two similar macros, one is a conditional formatting macro which
applies colour highlighting to specific rows; the other macro checks a cell value and updates the vale of the adjacent cell accordingly. Is there a way to combine then into one worksheet calculate event? Private Sub Worksheet_Calculate() Dim myC1 As Range Dim WatchRange1 As Range Application.ScreenUpdating = False Set WatchRange1 = Range("AwardValue") On Error Resume Next For Each myC1 In WatchRange1 If myC1.Cells.Value = "" Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 ElseIf myC1.Offset(0, 1).Value = "" Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 ElseIf myC1.Cells.Value < myC1.Offset(0, 1).Value Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 3 'red Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 3 'red Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 36 'yellow Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 36 'yellow Else Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 '0 Blank/Black '3 Red '36 Yellow '15 Grey '34 Light blue '16 Dark grey ' End If Next myC1 Application.ScreenUpdating = True End Sub '---------------------------------------------------------------------------------- Sub Update_CEStatus() Dim myC2 As Range Dim WatchRange2 As Range With Application .ScreenUpdating = False .Calculation = xlCalculationManual End With Set WatchRange2 = Range("Status") 'On Error Resume Next For Each myC2 In WatchRange2 If myC2.Cells.Value = "" _ Or myC2.Cells.Value = "Awaiting Payment" _ Or myC2.Cells.Value = "Awaiting Programme" _ Or myC2.Cells.Value = "Awaiting Construction" _ Or myC2.Cells.Value = "Cancelled" Then myC2.Offset(0, 1).Value = "Complete" ElseIf myC2.Cells.Value = "Forecast" _ Or myC2.Cells.Value = "Awaiting Quote" _ Or myC2.Cells.Value = "Awaiting Design" _ Or myC2.Cells.Value = "Awaiting Acceptance" _ myC2.Offset(0, 1).Value = "Ongoing" End If Next myC2 With Application .ScreenUpdating = False .Calculation = xlCalculationAutomatic End With End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Isn't it simply
Private Sub Worksheet_Calculate() Dim myC1 As Range Dim WatchRange1 As Range With Application .ScreenUpdating = False .Calculation = xlCalculationManual End With On Error Resume Next Set WatchRange1 = Range("AwardValue") For Each myC1 In WatchRange1 If myC1.Cells.Value = "" Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 ElseIf myC1.Offset(0, 1).Value = "" Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 ElseIf myC1.Cells.Value < myC1.Offset(0, 1).Value Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 3 'red Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 3 'red Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 36 'yellow Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 36 'yellow Else Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 '0 Blank/Black '3 Red '36 Yellow '15 Grey '34 Light blue '16 Dark grey ' End If Next myC1 Dim myC2 As Range Dim WatchRange2 As Range Set WatchRange2 = Range("Status") For Each myC2 In WatchRange2 If myC2.Cells.Value = "" _ Or myC2.Cells.Value = "Awaiting Payment" _ Or myC2.Cells.Value = "Awaiting Programme" _ Or myC2.Cells.Value = "Awaiting Construction" _ Or myC2.Cells.Value = "Cancelled" Then myC2.Offset(0, 1).Value = "Complete" ElseIf myC2.Cells.Value = "Forecast" _ Or myC2.Cells.Value = "Awaiting Quote" _ Or myC2.Cells.Value = "Awaiting Design" _ Or myC2.Cells.Value = "Awaiting Acceptance" Then myC2.Offset(0, 1).Value = "Ongoing" End If Next myC2 With Application .ScreenUpdating = True .Calculation = xlCalculationAutomatic End With End Sub -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "DDawson" wrote in message ... I have two similar macros, one is a conditional formatting macro which applies colour highlighting to specific rows; the other macro checks a cell value and updates the vale of the adjacent cell accordingly. Is there a way to combine then into one worksheet calculate event? Private Sub Worksheet_Calculate() Dim myC1 As Range Dim WatchRange1 As Range Application.ScreenUpdating = False Set WatchRange1 = Range("AwardValue") On Error Resume Next For Each myC1 In WatchRange1 If myC1.Cells.Value = "" Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 ElseIf myC1.Offset(0, 1).Value = "" Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 ElseIf myC1.Cells.Value < myC1.Offset(0, 1).Value Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 3 'red Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 3 'red Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 36 'yellow Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 36 'yellow Else Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 '0 Blank/Black '3 Red '36 Yellow '15 Grey '34 Light blue '16 Dark grey ' End If Next myC1 Application.ScreenUpdating = True End Sub '---------------------------------------------------------------------------------- Sub Update_CEStatus() Dim myC2 As Range Dim WatchRange2 As Range With Application .ScreenUpdating = False .Calculation = xlCalculationManual End With Set WatchRange2 = Range("Status") 'On Error Resume Next For Each myC2 In WatchRange2 If myC2.Cells.Value = "" _ Or myC2.Cells.Value = "Awaiting Payment" _ Or myC2.Cells.Value = "Awaiting Programme" _ Or myC2.Cells.Value = "Awaiting Construction" _ Or myC2.Cells.Value = "Cancelled" Then myC2.Offset(0, 1).Value = "Complete" ElseIf myC2.Cells.Value = "Forecast" _ Or myC2.Cells.Value = "Awaiting Quote" _ Or myC2.Cells.Value = "Awaiting Design" _ Or myC2.Cells.Value = "Awaiting Acceptance" _ myC2.Offset(0, 1).Value = "Ongoing" End If Next myC2 With Application .ScreenUpdating = False .Calculation = xlCalculationAutomatic End With End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Bob,
I wasn't sure about using Application.Calculation = xlCalculationManual with a Worksheet_Calculate event. Simple really! Regards Dylan "Bob Phillips" wrote: Isn't it simply Private Sub Worksheet_Calculate() Dim myC1 As Range Dim WatchRange1 As Range With Application .ScreenUpdating = False .Calculation = xlCalculationManual End With On Error Resume Next Set WatchRange1 = Range("AwardValue") For Each myC1 In WatchRange1 If myC1.Cells.Value = "" Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 ElseIf myC1.Offset(0, 1).Value = "" Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 ElseIf myC1.Cells.Value < myC1.Offset(0, 1).Value Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 3 'red Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 3 'red Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 36 'yellow Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 36 'yellow Else Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 '0 Blank/Black '3 Red '36 Yellow '15 Grey '34 Light blue '16 Dark grey ' End If Next myC1 Dim myC2 As Range Dim WatchRange2 As Range Set WatchRange2 = Range("Status") For Each myC2 In WatchRange2 If myC2.Cells.Value = "" _ Or myC2.Cells.Value = "Awaiting Payment" _ Or myC2.Cells.Value = "Awaiting Programme" _ Or myC2.Cells.Value = "Awaiting Construction" _ Or myC2.Cells.Value = "Cancelled" Then myC2.Offset(0, 1).Value = "Complete" ElseIf myC2.Cells.Value = "Forecast" _ Or myC2.Cells.Value = "Awaiting Quote" _ Or myC2.Cells.Value = "Awaiting Design" _ Or myC2.Cells.Value = "Awaiting Acceptance" Then myC2.Offset(0, 1).Value = "Ongoing" End If Next myC2 With Application .ScreenUpdating = True .Calculation = xlCalculationAutomatic End With End Sub -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "DDawson" wrote in message ... I have two similar macros, one is a conditional formatting macro which applies colour highlighting to specific rows; the other macro checks a cell value and updates the vale of the adjacent cell accordingly. Is there a way to combine then into one worksheet calculate event? Private Sub Worksheet_Calculate() Dim myC1 As Range Dim WatchRange1 As Range Application.ScreenUpdating = False Set WatchRange1 = Range("AwardValue") On Error Resume Next For Each myC1 In WatchRange1 If myC1.Cells.Value = "" Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 ElseIf myC1.Offset(0, 1).Value = "" Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 ElseIf myC1.Cells.Value < myC1.Offset(0, 1).Value Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 3 'red Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 3 'red Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 36 'yellow Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 36 'yellow Else Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 '0 Blank/Black '3 Red '36 Yellow '15 Grey '34 Light blue '16 Dark grey ' End If Next myC1 Application.ScreenUpdating = True End Sub '---------------------------------------------------------------------------------- Sub Update_CEStatus() Dim myC2 As Range Dim WatchRange2 As Range With Application .ScreenUpdating = False .Calculation = xlCalculationManual End With Set WatchRange2 = Range("Status") 'On Error Resume Next For Each myC2 In WatchRange2 If myC2.Cells.Value = "" _ Or myC2.Cells.Value = "Awaiting Payment" _ Or myC2.Cells.Value = "Awaiting Programme" _ Or myC2.Cells.Value = "Awaiting Construction" _ Or myC2.Cells.Value = "Cancelled" Then myC2.Offset(0, 1).Value = "Complete" ElseIf myC2.Cells.Value = "Forecast" _ Or myC2.Cells.Value = "Awaiting Quote" _ Or myC2.Cells.Value = "Awaiting Design" _ Or myC2.Cells.Value = "Awaiting Acceptance" _ myC2.Offset(0, 1).Value = "Ongoing" End If Next myC2 With Application .ScreenUpdating = False .Calculation = xlCalculationAutomatic End With End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dear Bob,
unfortunately, I was too quick in responding to this previously. I now find that when the two macros are combined, the routine goes into a loop and I have to press escape to cancel it. It would be nice to have a sheet that constantly updates the values of Update_CEStatus(). Instead, I have added the Update_CEStatus() to the macro that imports the latest database info into my workbook. This is the only time it really needs to be checked and updated. I look forward to reading any further advice regarding why the two macros wornt work together as a calculate event. Dylan -- "DDawson" wrote: Thanks Bob, I wasn't sure about using Application.Calculation = xlCalculationManual with a Worksheet_Calculate event. Simple really! Regards Dylan "Bob Phillips" wrote: Isn't it simply Private Sub Worksheet_Calculate() Dim myC1 As Range Dim WatchRange1 As Range With Application .ScreenUpdating = False .Calculation = xlCalculationManual End With On Error Resume Next Set WatchRange1 = Range("AwardValue") For Each myC1 In WatchRange1 If myC1.Cells.Value = "" Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 ElseIf myC1.Offset(0, 1).Value = "" Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 ElseIf myC1.Cells.Value < myC1.Offset(0, 1).Value Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 3 'red Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 3 'red Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 36 'yellow Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 36 'yellow Else Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 '0 Blank/Black '3 Red '36 Yellow '15 Grey '34 Light blue '16 Dark grey ' End If Next myC1 Dim myC2 As Range Dim WatchRange2 As Range Set WatchRange2 = Range("Status") For Each myC2 In WatchRange2 If myC2.Cells.Value = "" _ Or myC2.Cells.Value = "Awaiting Payment" _ Or myC2.Cells.Value = "Awaiting Programme" _ Or myC2.Cells.Value = "Awaiting Construction" _ Or myC2.Cells.Value = "Cancelled" Then myC2.Offset(0, 1).Value = "Complete" ElseIf myC2.Cells.Value = "Forecast" _ Or myC2.Cells.Value = "Awaiting Quote" _ Or myC2.Cells.Value = "Awaiting Design" _ Or myC2.Cells.Value = "Awaiting Acceptance" Then myC2.Offset(0, 1).Value = "Ongoing" End If Next myC2 With Application .ScreenUpdating = True .Calculation = xlCalculationAutomatic End With End Sub -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "DDawson" wrote in message ... I have two similar macros, one is a conditional formatting macro which applies colour highlighting to specific rows; the other macro checks a cell value and updates the vale of the adjacent cell accordingly. Is there a way to combine then into one worksheet calculate event? Private Sub Worksheet_Calculate() Dim myC1 As Range Dim WatchRange1 As Range Application.ScreenUpdating = False Set WatchRange1 = Range("AwardValue") On Error Resume Next For Each myC1 In WatchRange1 If myC1.Cells.Value = "" Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 ElseIf myC1.Offset(0, 1).Value = "" Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 ElseIf myC1.Cells.Value < myC1.Offset(0, 1).Value Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 3 'red Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 3 'red Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 36 'yellow Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 36 'yellow Else Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 '0 Blank/Black '3 Red '36 Yellow '15 Grey '34 Light blue '16 Dark grey ' End If Next myC1 Application.ScreenUpdating = True End Sub '---------------------------------------------------------------------------------- Sub Update_CEStatus() Dim myC2 As Range Dim WatchRange2 As Range With Application .ScreenUpdating = False .Calculation = xlCalculationManual End With Set WatchRange2 = Range("Status") 'On Error Resume Next For Each myC2 In WatchRange2 If myC2.Cells.Value = "" _ Or myC2.Cells.Value = "Awaiting Payment" _ Or myC2.Cells.Value = "Awaiting Programme" _ Or myC2.Cells.Value = "Awaiting Construction" _ Or myC2.Cells.Value = "Cancelled" Then myC2.Offset(0, 1).Value = "Complete" ElseIf myC2.Cells.Value = "Forecast" _ Or myC2.Cells.Value = "Awaiting Quote" _ Or myC2.Cells.Value = "Awaiting Design" _ Or myC2.Cells.Value = "Awaiting Acceptance" _ myC2.Offset(0, 1).Value = "Ongoing" End If Next myC2 With Application .ScreenUpdating = False .Calculation = xlCalculationAutomatic End With End Sub |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
As it is a calculate event, probably best not to mess with calculation
status Private Sub Worksheet_Calculate() Dim myC1 As Range Dim WatchRange1 As Range With Application .ScreenUpdating = False End With On Error Resume Next Set WatchRange1 = Range("AwardValue") For Each myC1 In WatchRange1 If myC1.Cells.Value = "" Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 ElseIf myC1.Offset(0, 1).Value = "" Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 ElseIf myC1.Cells.Value < myC1.Offset(0, 1).Value Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 3 'red Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 3 'red Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 36 'yellow Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 36 'yellow Else Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 '0 Blank/Black '3 Red '36 Yellow '15 Grey '34 Light blue '16 Dark grey ' End If Next myC1 Dim myC2 As Range Dim WatchRange2 As Range Set WatchRange2 = Range("Status") For Each myC2 In WatchRange2 If myC2.Cells.Value = "" _ Or myC2.Cells.Value = "Awaiting Payment" _ Or myC2.Cells.Value = "Awaiting Programme" _ Or myC2.Cells.Value = "Awaiting Construction" _ Or myC2.Cells.Value = "Cancelled" Then myC2.Offset(0, 1).Value = "Complete" ElseIf myC2.Cells.Value = "Forecast" _ Or myC2.Cells.Value = "Awaiting Quote" _ Or myC2.Cells.Value = "Awaiting Design" _ Or myC2.Cells.Value = "Awaiting Acceptance" Then myC2.Offset(0, 1).Value = "Ongoing" End If Next myC2 With Application .ScreenUpdating = True End With End Sub -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Dylan" wrote in message ... Dear Bob, unfortunately, I was too quick in responding to this previously. I now find that when the two macros are combined, the routine goes into a loop and I have to press escape to cancel it. It would be nice to have a sheet that constantly updates the values of Update_CEStatus(). Instead, I have added the Update_CEStatus() to the macro that imports the latest database info into my workbook. This is the only time it really needs to be checked and updated. I look forward to reading any further advice regarding why the two macros wornt work together as a calculate event. Dylan -- "DDawson" wrote: Thanks Bob, I wasn't sure about using Application.Calculation = xlCalculationManual with a Worksheet_Calculate event. Simple really! Regards Dylan "Bob Phillips" wrote: Isn't it simply Private Sub Worksheet_Calculate() Dim myC1 As Range Dim WatchRange1 As Range With Application .ScreenUpdating = False .Calculation = xlCalculationManual End With On Error Resume Next Set WatchRange1 = Range("AwardValue") For Each myC1 In WatchRange1 If myC1.Cells.Value = "" Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 ElseIf myC1.Offset(0, 1).Value = "" Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 ElseIf myC1.Cells.Value < myC1.Offset(0, 1).Value Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 3 'red Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 3 'red Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 36 'yellow Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 36 'yellow Else Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 '0 Blank/Black '3 Red '36 Yellow '15 Grey '34 Light blue '16 Dark grey ' End If Next myC1 Dim myC2 As Range Dim WatchRange2 As Range Set WatchRange2 = Range("Status") For Each myC2 In WatchRange2 If myC2.Cells.Value = "" _ Or myC2.Cells.Value = "Awaiting Payment" _ Or myC2.Cells.Value = "Awaiting Programme" _ Or myC2.Cells.Value = "Awaiting Construction" _ Or myC2.Cells.Value = "Cancelled" Then myC2.Offset(0, 1).Value = "Complete" ElseIf myC2.Cells.Value = "Forecast" _ Or myC2.Cells.Value = "Awaiting Quote" _ Or myC2.Cells.Value = "Awaiting Design" _ Or myC2.Cells.Value = "Awaiting Acceptance" Then myC2.Offset(0, 1).Value = "Ongoing" End If Next myC2 With Application .ScreenUpdating = True .Calculation = xlCalculationAutomatic End With End Sub -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "DDawson" wrote in message ... I have two similar macros, one is a conditional formatting macro which applies colour highlighting to specific rows; the other macro checks a cell value and updates the vale of the adjacent cell accordingly. Is there a way to combine then into one worksheet calculate event? Private Sub Worksheet_Calculate() Dim myC1 As Range Dim WatchRange1 As Range Application.ScreenUpdating = False Set WatchRange1 = Range("AwardValue") On Error Resume Next For Each myC1 In WatchRange1 If myC1.Cells.Value = "" Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 ElseIf myC1.Offset(0, 1).Value = "" Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 ElseIf myC1.Cells.Value < myC1.Offset(0, 1).Value Then Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 3 'red Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 3 'red Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 36 'yellow Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 36 'yellow Else Range(myC1, myC1.Offset(0, -7)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Font.ColorIndex = 0 Range(myC1, myC1.Offset(0, -7)).Interior.ColorIndex = 0 Range(myC1, myC1.Offset(0, 5)).Interior.ColorIndex = 0 '0 Blank/Black '3 Red '36 Yellow '15 Grey '34 Light blue '16 Dark grey ' End If Next myC1 Application.ScreenUpdating = True End Sub '---------------------------------------------------------------------------------- Sub Update_CEStatus() Dim myC2 As Range Dim WatchRange2 As Range With Application .ScreenUpdating = False .Calculation = xlCalculationManual End With Set WatchRange2 = Range("Status") 'On Error Resume Next For Each myC2 In WatchRange2 If myC2.Cells.Value = "" _ Or myC2.Cells.Value = "Awaiting Payment" _ Or myC2.Cells.Value = "Awaiting Programme" _ Or myC2.Cells.Value = "Awaiting Construction" _ Or myC2.Cells.Value = "Cancelled" Then myC2.Offset(0, 1).Value = "Complete" ElseIf myC2.Cells.Value = "Forecast" _ Or myC2.Cells.Value = "Awaiting Quote" _ Or myC2.Cells.Value = "Awaiting Design" _ Or myC2.Cells.Value = "Awaiting Acceptance" _ myC2.Offset(0, 1).Value = "Ongoing" End If Next myC2 With Application .ScreenUpdating = False .Calculation = xlCalculationAutomatic End With End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Combine Two Similar Arrays | Excel Worksheet Functions | |||
How to combine data from 100 similar Excel files | Excel Discussion (Misc queries) | |||
Help 2nd request (sumif formula of similar 17-04-08) | Excel Discussion (Misc queries) | |||
How do I combine quantities of similar line items | Excel Discussion (Misc queries) | |||
Find similar lines and combine | Excel Programming |