Place Name in selected Cell from UserName lookup result

chris186h

Board Regular
Joined
Mar 18, 2015
Messages
111
Hello all. I am struggling with this one.
What im trying to do is if a cell is selected in the range of C3:J30
it looks up the = Environ("username") in Settings!A1:B35 (A-usernames, B-Actual Name)
and places the Actual Name in the selected cell.
Then if the cell is selected again when it contains a value it removes the name

Many thanks for any help in advance
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
if i understand this code in sheet code module will insert username in any cell in range C3:J30 as soon as selected

i have pout comment line so you can select which username you would like

i am not sure on the remove name code as if re-selected it would put current user name

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(ActiveCell, Range("C3:J30")) Is Nothing Then
ActiveCell.Value = Application.UserName
'ActiveCell.Value = Environ("username")
End If
End Sub

you could put another IF

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(ActiveCell, Range("C3:J30")) Is Nothing Then
If ActiveCell.Value = "" Then
ActiveCell.Value = Application.UserName
'ActiveCell.Value = Environ("username")
Else
ActiveCell.Value = ""
End If

End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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