Badawi Aminu Muhammed

Badawi Aminu Muhammed

Data Analyst • Business Intelligence Expert • Research Scientist

← Back to Projects

HR_Searchbar_automation

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)

You can record your screen using Xbox Game Bar (Windows + G) or Mac Screen Recorder (Command + Shift + 5), then save it as excel_search_demo.mp4 in your project root.


📸 Screenshots

Search Interface Results Display
Search Interface Results Display

🗂️ Folder Structure

Excel-Employee-Search-VBA/
│
├── README.md
├── EmployeeSearch.xlsm
├── excel_search_demo.mp4
└── 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 VBAActiveX ControlsAutomationData CleaningSearch FunctionHR Analytics