[英]Excel VBA Change Value in another column and row in range
I have problem in my code, i need to change in another column - row 我的代码有问题,我需要更改另一列 - 行
I tried to built macro but it's dosn't work with that. 我试图构建宏但它不适用于此。
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xRg As Range
On Error Resume Next
Set xRg = Intersect(Target, Range("A6:U1000"))
If xRg Is "YES" Then Exit Sub
Range("G" & Target.Row).Value = "CHECK"
End Sub
When in column N6:N1000 is "YES" in Column G change value to "Check" and all row A6 for example to U1000 is in color red 当在列N6中:N1000在列G中为“是”时将值改为“检查”,并且例如对于U1000的所有行A6为红色
I can't quite understand what you're trying to achieve here, but hopefully the below will be doing roughly what you need. 我不太明白你在这里想要达到的目标,但希望下面的内容大致可以满足您的需求。 Try it and let me know if it doesn't behave the way you hope.
尝试一下,让我知道它是否表现得不像你希望的那样。
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
Dim xRg As Range, cl as Range
Set xRg = Intersect(Target, Range("A6:U1000"))
If Not xRg Is Nothing Then
For Each cl In xRg.Cells
If cl.Value = "YES" Then Range("G" & cl.Row).Value = "CHECK"
Next
End If
Application.EnableEvents = True
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.