Excel Employee Search & Automation System (VBA Project)

πŸ“˜ Overview

This project demonstrates how to use Excel VBA and ActiveX Controls to create a functional and automated Employee Record Search System.
It combines clean data management, user-friendly search capability, and dynamic column formatting β€” all within Microsoft Excel.


βš™οΈ Features


🧭 Setup Guide

1️⃣ Enable ActiveX Controls (Trust Center Configuration)

Before running any VBA macros, ensure that Excel can execute ActiveX components safely.

  1. Go to File β†’ Options β†’ Trust Center β†’ Trust Center Settings
  2. Click ActiveX Settings
    • βœ… Enable all controls without restrictions
    • βœ… Prompt me before enabling unsafe ActiveX controls
  3. Click Macro Settings
    • βœ… Enable all macros
    • βœ… Trust access to the VBA project object model
  4. Save and restart Excel.

2️⃣ Prepare Workbook Sheets

Sheet Name Purpose
Search Interface User search input and results display
EmployeeData Holds full dataset (31 columns, starting from Row 1)

3️⃣ VBA Code Setup

πŸ”Έ Search Function (Paste in CommandButton code)

Private Sub CommandButton1_Click()
    Dim wsData As Worksheet, wsSearch As Worksheet
    Dim searchValue As String
    Dim lastRow As Long, destRow As Long
    Dim cell As Range, rng As Range

    Set wsData = ThisWorkbook.Sheets("EmployeeData")
    Set wsSearch = ThisWorkbook.Sheets("Search Interface")

    searchValue = Trim(wsSearch.TextBox1.Text)
    If searchValue = "" Then
        MsgBox "Please enter a search term.", vbExclamation
        Exit Sub
    End If

    wsSearch.Rows("7:" & wsSearch.Rows.Count).ClearContents

    lastRow = wsData.Cells(wsData.Rows.Count, "A").End(xlUp).Row
    Set rng = wsData.Range("A2:A" & lastRow)
    destRow = 7

    For Each cell In rng
        If InStr(1, cell.Value, searchValue, vbTextCompare) > 0 _
            Or InStr(1, cell.Offset(0, 1).Value, searchValue, vbTextCompare) > 0 Then
            cell.EntireRow.Copy wsSearch.Cells(destRow, "A")
            destRow = destRow + 1
        End If
    Next cell

    If destRow = 7 Then
        MsgBox "No matching records found.", vbInformation
    Else
        MsgBox "Search completed.", vbInformation
    End If
End Sub

πŸ”Έ AutoFit Columns on Sheet Activation

(Paste this into the β€œSearch Interface” sheet module)

Private Sub Worksheet_Activate()
    Cells.EntireColumn.AutoFit
End Sub

🧩 Project Logic Summary

  1. The user enters a search keyword (Employee ID or Name).
  2. VBA loops through EmployeeData (Sheet2).
  3. If a match is found, the entire row is copied to Search Interface (Sheet1) starting from Row 7.
  4. When the sheet is reactivated, columns automatically resize for clarity.

This setup is ideal for HR dashboards, employee directories, or data filtering tools.


🧠 Snapshot Section

πŸ“Ί Watch the Demo
(Click image to view recorded demo)

Demo preview is shown in the linked screenshot above.


πŸ“Έ Screenshots

Search Interface Results Display
Search Interface Results Display

πŸ—‚οΈ Folder Structure

Excel-Employee-Search-VBA/
β”‚
β”œβ”€β”€ README.md
β”œβ”€β”€ EmployeeSearch.xlsm
β”œβ”€β”€ results_display.png
└── screenshots/
    β”œβ”€β”€ search_interface.png
    └── results_display.png

πŸ§‘β€πŸ’» Author

Badawi Aminu Muhammed
Data Analyst | Business Intellince Specialist | Researcher Scientist
πŸ“§ cigma.generalsolutions@gmail.com
🌐 linkedin.com/in/elameenbadawy

Cigma General Solutions β€” "…significant difference"


πŸ’‘ Notes


🌟 Tags

Excel VBA β€’ ActiveX Controls β€’ Automation β€’ Data Cleaning β€’ Search Function β€’ HR Analytics