“Object required” error 424

心已入冬 提交于 2019-12-11 19:28:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!