146 lines
5.0 KiB
Plaintext
Raw Normal View History

2025-02-28 06:08:01 +01:00
**User Manual for Excel Filtering System**
---
## **Introduction**
This manual provides step-by-step instructions on how to use the Excel-based filtering system to generate reports based on selected criteria, such as Year, Program, and County. It also explains how to reset filters and clear reports.
---
## **1. System Components**
### **1.1 Dashboard Sheet**
- The main interface for interacting with the data.
- Contains filter options and action buttons.
- Displays filtered results from the "Datasheet".
### **1.2 Datasheet**
- Stores the raw data that is used for filtering and reporting.
- Contains columns such as ID, Beneficiary Name, Program, Year, Business Type/Course, and County of Residence.
### **1.3 VBA Code Module**
- Automates data extraction based on selected filters.
- Provides functionalities such as generating reports, resetting filters, and clearing reports.
---
## **2. Using the System**
### **2.1 Applying Filters**
1. **Navigate to the Dashboard sheet.**
2. **Select filter values:**
- Choose a Year from the dropdown under "Year".
- Select a Program from the dropdown under "Program".
- Select a County from the dropdown under "County".
3. **Click the "Apply Filters" button.**
- The system will filter data from the "Datasheet" and display results in the Dashboard.
- If no matching records are found, a message box will notify you.
### **2.2 Resetting Filters**
1. **Click the "Reset Filters" button.**
2. This will remove all applied filters and display the entire dataset in the Dashboard.
### **2.3 Generating County Reports**
1. **Ensure filters are correctly set (Year, Program, County).**
2. **Click the "Generate County Reports" button.**
3. The system will extract and display relevant data in the Dashboard.
### **2.4 Clearing Reports**
1. **Click the "Reset/Clear Reporting" button.**
2. This will clear all previously displayed data from the Dashboard.
---
## **3. Technical Details**
### **3.1 VBA Code for Filtering Data**
The VBA macro automatically applies filters and copies the relevant data to the Dashboard.
```vba
Sub FilterAndExtractData()
Dim wsData As Worksheet, wsDash As Worksheet
Dim lastRow As Long, headerRow As Long
Dim yearFilter As String, programFilter As String, countyFilter As String
Dim filterRange As Range, copyRange As Range
' Set references to sheets
Set wsData = ThisWorkbook.Sheets("Datasheet")
Set wsDash = ThisWorkbook.Sheets("Dashboard")
' Define last row of data
lastRow = wsData.Cells(wsData.Rows.Count, 1).End(xlUp).Row
headerRow = 1
' Get filter values from Dashboard
yearFilter = wsDash.Range("B7").Value
programFilter = wsDash.Range("C7").Value
countyFilter = wsDash.Range("D7").Value
' Clear previous results
wsDash.Range("A10:L35").ClearContents
' Set filter range
Set filterRange = wsData.Range(wsData.Cells(headerRow, 1), wsData.Cells(lastRow, wsData.UsedRange.Columns.Count))
' Apply AutoFilter
filterRange.AutoFilter Field:=3, Criteria1:=yearFilter
filterRange.AutoFilter Field:=2, Criteria1:=programFilter
filterRange.AutoFilter Field:=5, Criteria1:=countyFilter
' Check if visible cells exist
On Error Resume Next
Set copyRange = filterRange.Offset(1, 0).Resize(filterRange.Rows.Count - 1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not copyRange Is Nothing Then
wsData.Rows(headerRow).Copy Destination:=wsDash.Rows(9)
copyRange.Copy
wsDash.Cells(10, 1).PasteSpecial Paste:=xlPasteValues
wsDash.Cells(10, 1).PasteSpecial Paste:=xlPasteFormats
Application.CutCopyMode = False
Else
MsgBox "No records found for selected filters!", vbExclamation
End If
' Turn off AutoFilter
wsData.AutoFilterMode = False
End Sub
```
### **3.2 VBA Code for Clearing Reports**
```vba
Sub ClearReportsButton()
Dim ws As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each ws In ThisWorkbook.Sheets
If ws.Name <> "Dashboard" And ws.Name <> "Datasheet" And ws.Name <> "Code" Then
ws.Delete
End If
Next ws
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "All county reports have been cleared!", vbInformation
End Sub
```
---
## **4. Troubleshooting**
| **Issue** | **Solution** |
|-----------|-------------|
| "No records found for selected filters!" | Ensure the selected filter values exist in the "Datasheet". |
| "Error when applying filters" | Check if the headers in "Datasheet" match the VBA filter fields. |
| "Clear Reports button not working" | Ensure the correct sheet names are being referenced in the code. |
---
## **5. Conclusion**
This Excel filtering system allows users to efficiently filter and extract data based on selected criteria. With the provided VBA scripts, users can automate data extraction, reset filters, and clear reports easily. If any modifications are needed, update the VBA code accordingly.
For further assistance, please contact the system administrator.