need VBA to allow Double click on Employee Name and it will take me to the employee name on another sheet

time4tg

New Member
Joined
Jun 7, 2022
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I have some knowledge of VBA, but not very proficient. I am looking if someone could help me with my workbook issue. I have a spreadsheet that I get filled with a lot of data for employees. On separate sheets I have a list of the employee names with summary information that I pulled from the original worksheet. I want to be able to double click on the employee name and take it to the data worksheet so that I can see the detail
Sheet 1

Util Report Sample.xlsx
BCDE
3HL
4Employee 1 - TotalEmployee 1146.3%
5Employee 2 - TotalEmployee 259.6%
6
Sheet1
Cell Formulas
RangeFormula
D4:D5D4=VLOOKUP($B4,Sheet2!$H:AI,5,0)


Sheet 2

Util Report Sample.xlsx
ABCDEFGHIJKLM
1
2Title
3WeekUser RoleGeoMarketMain DepartmentCountryYearMonthWeekLOBEmp StatusMajorPractitioner
4January, February, March, April, May
5
6Report Selection
7User RoleTypeViewShow Activity Details
8
9
10
11
12GeoMarketCountryMain DepartmentMajorLine of Business
13
14YearMonthWeekEmployee StatusPractitioner
15
16
17
18Employee (6pos)
19
20Department Nbr (7pos)
21
22
23
24
25
26Report creation Time :
27ABCDEFGHIJKLM
28PlaceRegionArea000Manager 1XXXXXX1Employee 101XXXXJanuary01146.3%
29January - Total146.3%
30Employee 1 - Total146.3%
31xxxxxx1 - Total146.3%
32Manager 1 - Total146.3%
33Manager 2XXXXX2Employee 202XXXXJanuary014.8%
34020.0%
350359.3%
360439.8%
37050.0%
38January - Total20.8%
39February06113.5%
4007102.0%
410884.0%
420987.5%
43February - Total96.8%
44March1075.0%
451187.8%
461265.0%
471357.5%
48March - Total71.3%
49April1438.0%
501581.5%
511685.5%
521751.8%
53April - Total64.2%
54May1842.5%
551988.0%
562057.5%
572131.0%
58May - Total54.8%
59Employee 2 - Total59.6%
Sheet2
 

Attachments

  • 1654647634314.png
    1654647634314.png
    3.2 KB · Views: 7
  • 1654647818932.png
    1654647818932.png
    46.8 KB · Views: 7

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
You said:
I want to be able to double click on the employee name and take it to the data worksheet so that I can see the detail

So where are these employee names?
And you said "Take it"

Does that mean activate the sheet?
So if you double click on "Alpha" Sheet named "Alpha" will be activated.
Is that what you want?
So tell me are these sheet names in column A and you want to double click on a cell in column A and be taken to the sheet name you double click on. Is that correct? If not please explain with more specific details
 
Upvote 0
You said:
I want to be able to double click on the employee name and take it to the data worksheet so that I can see the detail

So where are these employee names?
And you said "Take it"

Does that mean activate the sheet?
So if you double click on "Alpha" Sheet named "Alpha" will be activated.
Is that what you want?
So tell me are these sheet names in column A and you want to double click on a cell in column A and be taken to the sheet name you double click on. Is that correct? If not please explain with more specific details
I just used names of Employee 1 and Employee 2. In Sheet I just have 3 columns, Employee 1 - Total, Employee 1 and the percent listed in column L from Sheet 2. Sheet 2 has the employee name in Column H. When I am looking at the information in Sheet one, I would like to be able to double click on Employee 1 (the name) and it will take you to Sheet 2 to that matching employee name. ()this name is in column H on Sheet 2) Hope that explains better.
 

Attachments

  • Sheet 1.JPG
    Sheet 1.JPG
    18.7 KB · Views: 6
  • Sheet 2.JPG
    Sheet 2.JPG
    47.4 KB · Views: 5
Upvote 0
Assuming your sheet name is "Sheet 2" like in your image
And not "Sheet2")
There is a differents.

This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

Put this script in the sheet where you plan to double click on a cell in column H

VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified  6/7/2022  10:17:45 PM  EDT
If Target.Column = 8 Then
Cancel = True
Dim ans As String
Dim SearchString As String
Dim SearchRange As Range
SearchString = Target.Value
Dim lastrow As Long
lastrow = Sheets("Sheet 2").Cells(Rows.Count, "H").End(xlUp).Row
Set SearchRange = Sheets("Sheet 2").Range("H1:H" & lastrow).Find(SearchString, LookIn:=xlValues, lookat:=xlWhole)
If SearchRange Is Nothing Then MsgBox SearchString & "  Not Found": Exit Sub
ans = SearchRange.Address
Application.Goto Sheets("Sheet 2").Range(ans)
End If
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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