如果该列中任何单元格的值为"T",我想调用宏,但每次都会出现运行时错误:Type Mismatch为If Target.Value = "T" Then
的线。有人能帮我一下吗?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 36 Then
ThisRow = Target.Row
If Target.Value = "T" Then
Range("AJ" & ThisRow).Select
Call mail_outlook
End If
End If
End Sub
谢谢你。
您可能有一个单元格有一个错误在它…您可以像这样检查该条件:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not IsError(Target) Then
If Target.Column = 36 Then ' AJ
ThisRow = Target.Row
If Target.Value = "T" Then
Range("AJ" & ThisRow).Select
Call mail_outlook
End If
End If
End If
End Sub
另外,您可以检查Target
以查看所选的单元格是否多于一个(如果有帮助的话)
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count = 1 Then
If Target.Column = 36 Then ' AJ
ThisRow = Target.Row
If Target.Value = "T" Then
Range("AJ" & ThisRow).Select
Call mail_outlook
End If
End If
End If
End Sub