-
There is a default variable Target which will be your active cell (unless you selected a range of cells), and can be referenced in the code.
[VBA]
If Not s Is Nothing Then 'if there is an overlap
Cancel = True
With Target
.Value = usernameLookup(Application.UserName)
'update the cell with the username
.Offset(0, 1).Value = Now()
'update the adjacent cell with the date and time
End With
End If
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules