Employee ID issue in overall PMS report to handle with Macros

Created by Support L2, Modified on Fri, 20 Jun at 6:53 PM by Support L2


Steps to Run the Macro (Employee ID Cleanup) in Excel

Step 1: Open Excel and Press Alt + F11

  • This opens the Visual Basic for Applications (VBA) editor.


Step 2: Insert the VBA Script

  1. In the left pane, under VBAProject, double-click on ThisWorkbook.

  2. Paste the following macro code:



Sub Employeeid()
    Dim ws As Worksheet
    Dim lastRow As Long
    Dim i As Long


    Set ws = ThisWorkbook.Sheets(1) ' Change index or name as needed
    lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row


    For i = 4 To lastRow
        With ws.Cells(i, "A")
            If Len(.Value) > 1 Then
                .Value = Mid(.Value, 2)
            End If
        End With
    Next i
End Sub

Step 3: Close the VBA Editor

  • Press Ctrl + S to save the macro.

  • Close the editor or press Alt + Q to return to Excel.


Step 4: Run the Macro

  1. Press Alt + F8 to open the Macro window.

  2. Select ThisWorkbook.Employeeid.

  3. Click “Run”.



The macro will process values in Column A, starting from row 4, and remove the first character of each cell value.


? Notes:

  • Save your workbook as .xlsm to retain the macro.

  • Always run the macro on a copy of your data to prevent accidental data loss.

  • ⚠️ This macro can be run multiple times, but it will keep removing the first character of each cell in Column A on every run.
    Example: E12345123452345345, etc.
    To avoid this, ensure the macro is run only once on each dataset, or implement a condition to check the first character (e.g., only remove if it starts with "E").





Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article