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: 8

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
60,951
Office Version
  1. 365
Platform
  1. Windows
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’)
 

Harry_T

New Member
Joined
Sep 27, 2017
Messages
8
Office Version
  1. 365
Platform
  1. Windows
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: 8

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
68,283
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

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.
 

Harry_T

New Member
Joined
Sep 27, 2017
Messages
8
Office Version
  1. 365
Platform
  1. Windows
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!
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
60,951
Office Version
  1. 365
Platform
  1. Windows
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.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,489
Messages
5,770,388
Members
425,615
Latest member
tomenzo123

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
Top