Display name on pay stub summary

Bob_ipc

Board Regular
Joined
Oct 18, 2017
Messages
67
Office Version
  1. 365
Platform
  1. Windows
I have a list of employee names from A11:A70, and this list is filtered, How can I display a name in E3 when I select it from my filter list?
Example: if I filter (Smith, John) from my filter his name appears in E3, if I filter (Dow, Jane) from my filter list then her name appears in E3.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Rather than filtering manually, run this macro. It will prompt you to enter the employee name, filter the data and populate E3.
Code:
Sub Test()
    Dim response
    response = InputBox("Please enter the employee name.")
    ActiveSheet.Range("$A$10:$A$70").AutoFilter Field:=1, Criteria1:=response
    Range("E3") = response
End Sub
or you can place this macro in the worksheet code module:
Code:
Private Sub Worksheet_selectionChange(ByVal Target As Range)
    If Intersect(Target, Range("A11:A70")) Is Nothing Then Exit Sub
    Range("E3") = Target
End Sub
When you click on a name after filtering manually, it will show up in E3.
 
Last edited:
Upvote 0
Thanks Mumps, I appreciate you helping out. I am really new to using Macros, as in I have never run one before, I did attempt to enter the code you provided but I had no luck.
after adding the code and saving as a macro enabled file, I then hit F8 to run it but nothing would show up on the list
 
Upvote 0
The first macro goes into a regular module by doing the following: Hold down the ALT key and press the F11 key. This will open the Visual Basic Editor. In the menu at the top click 'Insert' and then click 'Module'. Copy and paste the macro into the empty code window that opens up. Press the F5 key to run the macro. Close the code module window to return to your sheet. There are other quicker ways to run the macro such as assigning it to a button that you would click on your sheet or assigning it to a short cut key.

The second macro goes into the worksheet code module by doing the following: right click the tab for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. This macro runs automatically when you click on a name in column A. You can use one method or both. Please let me know how things work out.
 
Upvote 0
Oh cool! That is awesome! the second method will work great for what I am trying to do! Thank you so much!
 
Upvote 0

Forum statistics

Threads
1,214,797
Messages
6,121,629
Members
449,041
Latest member
Postman24

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