问题
I have 2 sheets List
and Comments
.
List
is auto updated from another sheet that imports and formats data
I want to keep track of how often we use each object in sheet List
by double clicking on the ID cell (Range("List!$B$6:$B$22"))
but as the data is always changing the ID's move around.
the Comments
which is a list of all possible ID's and its comments but not the imported values would be a good place to store count data and last used date.
Private Sub WorkSheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If InRange(Target, Range("List!$B$6:$B$22")) Then
Set c = Worksheets("Comments").Range("$A$2:$A$500").Find(Target.Value)
If Not c Is Nothing Then
Set c.Offset(0, 1) = c.Offset(0, 1) + 1
Set c.Offset(0, 2) = Date
End If
End If
Cancel = True
End Sub
回答1:
No need to Set
Private Sub WorkSheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("$B$6:$B$22")) Is Nothing Then
Set c = Worksheets("Comments").Range("$A$2:$A$500").Find(Target.Value)
If Not c Is Nothing Then
c.Offset(0, 1) = c.Offset(0, 1) + 1
c.Offset(0, 2) = Date
End If
End If
Cancel = True
End Sub
来源:https://stackoverflow.com/questions/23083627/object-required-error-424