✅ 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
In the left pane, under
VBAProject
, double-click onThisWorkbook
.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
Press
Alt + F8
to open the Macro window.Select
ThisWorkbook.Employeeid
.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:E12345
→12345
→2345
→345
, 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
Feedback sent
We appreciate your effort and will try to fix the article