Forum Discussion

Blixem's avatar
Blixem
Copper Contributor
Jun 30, 2026

Excel Help

Is there a way (either formula or macro /something) for the following. 

 

I have 2 different spread sheets (files) open at the same time. 

First is called Time Card

Second is called Wages

Time Card will have a staff members details as well as dates and shift times. (20 Tabs for different staff members and their details) 

 

Wages will have

Tab 1 - Summary of all staff names, hourly rates, hours worked for each day and gross amounts to be paid

Tab 2 - 20 payslips with the above mentioned details, but payslip style. 

 

Lets call the first person Joe Deer

I need something in Time Card next or close, to this person's name, when clicking it it will jump to his payslip in Wages sheet

 

As mentioned. Formula or macro.. Guess anything will do. 

 

Thanks

 

1 Reply

  • NikolinoDE's avatar
    NikolinoDE
    Platinum Contributor

    Here’s a clean, reliable way to jump from a staff name in your Time Card workbook straight to the matching payslip in the Wages workbook. I’ll give you a simple formula first, followed by a short and safe VBA macro in case you prefer a clickable button.

     

    Formula Solution (no VBA)

    Place this formula in your Time Card workbook next to the staff name (e.g., in cell B2 if the name is in A2):

    =HYPERLINK("[Wages.xlsx]" & "'" & A2 & "'!A1","View Payslip")

    Why it works...

    • The single quotes around the sheet name handle spaces correctly (e.g., 'Joe Deer').
    • The workbook reference [Wages.xlsx] ensures the link jumps to the correct file.
    • Both workbooks must be open at the same time.
    • The payslip sheet names in Wages must exactly match the staff names in your Time Card.

     

    Short, Safe VBA Alternative (button click)

    If you’d rather use a clickable button next to each name, add this macro to a standard module in the Time Card workbook:

    Sub GoToPayslip()
        Dim btn As Shape, empName As String, ws As Worksheet
    
        Set btn = ActiveSheet.Shapes(Application.Caller)
        empName = Trim(btn.TopLeftCell.Offset(0, -1).Value)
    
        If empName = "" Then
            MsgBox "No name found left of the button.", vbExclamation
            Exit Sub
        End If
    
        On Error Resume Next
        Set ws = Workbooks("Wages.xlsx").Sheets(empName)
        On Error GoTo 0
    
        If ws Is Nothing Then
            MsgBox "Sheet '" & empName & "' not found in Wages.", vbExclamation
        Else
            ws.Activate
        End If
    End Sub

    How to use it

    1. Insert a shape (e.g., a rectangle) immediately to the right of the name cell.
    2. Right-click the shape → Assign Macro → choose GoToPayslip.
    3. Copy the shape to other staff rows as needed – it automatically reads the name from the cell on its left.

    This macro is non-intrusive (only fires when you click the button) and handles missing names, closed workbooks, and mismatched sheet names gracefully.

     

    My recommendationUse the HYPERLINK formula for the quickest, maintenance-free solution. Choose the VBA button if you want a deliberate click target that doesn’t interfere with normal sheet navigation.

     

     

    My answers are voluntary and without guarantee!

     

    Hope this will help you.

     

    Was the answer useful? Mark as best response and like it!

    This will help all forum participants.