Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm trying to create a validation macro to enter text into the cell of range
G:G depending on the contents of the adjacent cells in columns C and D. This is what I have done to start with, there are other ElseIf entries to be added, but it is really slow to start with. Private Sub Worksheet_Calculate() Dim myC As Range Dim WatchRange1 As Range With Application .ScreenUpdating = False .Calculation = xlCalculationManual End With Set WatchRange1 = Range("G2:G500") For Each myC In WatchRange1 If myC.Offset(0, -3).Value = "Contract1" And _ myC.Offset(0, -4).Value = "Status A" Then myC.Cells.Value = "Response A" ElseIf myC.Offset(0, -3).Value = "Contract 2" And _ myC.Offset(0, -4).Value = "Status A" Then myC.Cells.Value = "Response B" Else: myC.Cells.Value = "" End If Next myC With Application .ScreenUpdating = True .Calculation = xlCalculationAutomatic End With End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use the worksheet Change event rather than the Calculate event. Target will
allow you to examine only a single pair of cells rather than all the pairs of cells. -- Gary''s Student - gsnu200769 "DDawson" wrote: I'm trying to create a validation macro to enter text into the cell of range G:G depending on the contents of the adjacent cells in columns C and D. This is what I have done to start with, there are other ElseIf entries to be added, but it is really slow to start with. Private Sub Worksheet_Calculate() Dim myC As Range Dim WatchRange1 As Range With Application .ScreenUpdating = False .Calculation = xlCalculationManual End With Set WatchRange1 = Range("G2:G500") For Each myC In WatchRange1 If myC.Offset(0, -3).Value = "Contract1" And _ myC.Offset(0, -4).Value = "Status A" Then myC.Cells.Value = "Response A" ElseIf myC.Offset(0, -3).Value = "Contract 2" And _ myC.Offset(0, -4).Value = "Status A" Then myC.Cells.Value = "Response B" Else: myC.Cells.Value = "" End If Next myC With Application .ScreenUpdating = True .Calculation = xlCalculationAutomatic End With End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to determine the worksheet that a calculate event gets initiated on when the workbook is not active | Excel Programming | |||
Change event and calculate event | Excel Programming | |||
Event Procedures: Event on Worksheet to fire Event on another Worksheet | Excel Programming | |||
Worksheet Calculate Event | Excel Programming |