VBA to return user ID

Harry_T

New Member
Joined
Sep 27, 2017
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hi Everyone,

I have an excel workbook that I made as a tracker. I had a macro to insert the individual's user name and the date in the cell immediately to the right of the selected cell upon double click. It worked the last time I was using this sheet but have switched jobs and would like to modify the sheet to use for my current needs. I'm just not sure why this error is now popping up. Any help would be appreciated. Thanks in advance!

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("j3:ai350")) Is Nothing Then
Cancel = True
Target.Value = Environ("username")
Target.Offset(0, 1) = Date
End If
End Sub
 

Attachments

  • Capture.PNG
    Capture.PNG
    113.5 KB · Views: 14

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Sounds like you may be missing a library reference.
If you go into the VB Editor, and go to Tools -> References, do you see any listed at the top with the word "MISSING" in it?

Also, I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
Sounds like you may be missing a library reference.
If you go into the VB Editor, and go to Tools -> References, do you see any listed at the top with the word "MISSING" in it?

Also, I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
Hi Joe4,

I've updated my account details as you've suggested. I'm currently using office 365.

I've gone into VBA and looked in the Tool > References and see one of the references with the phrase "missing" in it. I've attached a snip-it of the reference that is selected so you can see it. Thanks!
 

Attachments

  • Capture1.PNG
    Capture1.PNG
    17 KB · Views: 17
Upvote 0
You are unlikely to have the mscomct2.ocx on your system as it was discontinued a long time ago. If you are using a 32bit install of Office then you could download & register it, but if you are using a 64bit version you're out of luck.
 
Upvote 0
Take a look here for resolving that issue: Missing References In VBA
Thank you for sharing that link. I read the article and tried the simple suggestion of unselecting the problem reference to see if that would resolve the problem. I unselected the missing reference, closed out of all excel workbooks, and then re-opened the file with my macros and it was working again. Success!
 
Upvote 0
Thank you for sharing that link. I read the article and tried the simple suggestion of unselecting the problem reference to see if that would resolve the problem. I unselected the missing reference, closed out of all excel workbooks, and then re-opened the file with my macros and it was working again. Success!
Excellent!
I am glad to hear it was able to help you resolve your issue.
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top