我想要实现的是,例如,用户在 B 列中输入一个值,如果它低于限制(比如 50),那么您查看 A 列中的日期并将该日期的工作表标签颜色更改为红色,如果它50以下。
但是,我在将 target.adress 放入变量时遇到问题,并且我不断收到类型不匹配错误。
这就是我目前所拥有的。
Private Sub Worksheet_Change(ByVal Target As Range)
Dim R as integer
dim c as integer
Dim cl As Range
Dim Tb As Range
Dim RG As Range
Set RG = Intersect(Target, Range("B2:B50"))
Set Tb = Target.Address
Set r = Tb.row
Set c = Tb.column - 1
Set cl = cells(R,C).value
Set cl = Replace(cl, "/", ".")
If RG Is Nothing Then
Exit Sub
ElseIf Target.Value < 50 Then
cl.Tab.Color = vbRed
End If
End Sub
无论我做什么,set tb = target.address 似乎都不起作用。
任何帮助表示赞赏。
最佳答案
这可能会帮助您:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim tb
Dim Row As Long
Dim Col As Long
If Not Intersect(Target, Me.Range("A1:A10")) Is Nothing Then
tb = Target.Address
Row = Target.Row
Col = Target.Column
End If
End Sub
关于excel - 将 Target.Address 存储在变量中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59372350/