winxmun
06-18-2010, 03:45 AM
Hi,
I hv a VBA code as below that was written by somebody else. I am trying to add another range other than the existing range, ie "Claimed", "Closed". However I encounterred error by adding another new range. Anybody know how to overcome this error. Thanks a lot!
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As Boolean)
'When the worksheet is double clicked return the range using the variable name 'target'
'------ Update UserName on DoubleClick ------
Dim s
'Dim n As String
Set s = Application.Intersect(Target, Range("Claimed", "Closed"))
's is the overlap between the double clicked range and our two pre-defined ranges
If Not s Is Nothing Then 'if there is an overlap
ActiveCell.Value = usernameLookup(Application.UserName)
'update the cell with the username
ActiveCell.Offset(0, 1).Value = Now()
'update the adjacent cell with the date and time
ActiveCell.Offset(0, 1).Activate
'move to the adjacent cell so that double clicked cell is not left in edit mode
End If
'/----- Update UserName on DoubleClick ------
Application.EnableEvents = True
End Sub
I hv a VBA code as below that was written by somebody else. I am trying to add another range other than the existing range, ie "Claimed", "Closed". However I encounterred error by adding another new range. Anybody know how to overcome this error. Thanks a lot!
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As Boolean)
'When the worksheet is double clicked return the range using the variable name 'target'
'------ Update UserName on DoubleClick ------
Dim s
'Dim n As String
Set s = Application.Intersect(Target, Range("Claimed", "Closed"))
's is the overlap between the double clicked range and our two pre-defined ranges
If Not s Is Nothing Then 'if there is an overlap
ActiveCell.Value = usernameLookup(Application.UserName)
'update the cell with the username
ActiveCell.Offset(0, 1).Value = Now()
'update the adjacent cell with the date and time
ActiveCell.Offset(0, 1).Activate
'move to the adjacent cell so that double clicked cell is not left in edit mode
End If
'/----- Update UserName on DoubleClick ------
Application.EnableEvents = True
End Sub