Compare commits

...

13 Commits

Author SHA1 Message Date
affc598864 Merge pull request '3.0' (#8) from agtic/MS_Excel_VBA_Reporting_Template:3.0 into mastre
Reviewed-on: Nestict_Infotech/MS_Excel_VBA_Reporting_Template#8
2025-03-02 14:36:41 +01:00
07cb2e64e4 merge upstream 2025-03-02 14:33:31 +01:00
d52839d6cb Update ResetFilters/ResetFilters.bas 2025-03-02 14:26:05 +01:00
25e930145c Update ReportPerCounty/ReportPerCounty.bas 2025-03-02 14:25:04 +01:00
f0503dd266 Update FilterAndExtractData/FilterAndExtractData.bas 2025-03-02 14:24:11 +01:00
c7080f0a2f Update DetailedReport/DetailedReport.bas 2025-03-02 14:22:49 +01:00
b2e084bd10 Update ClearReports/ClearReports.bas 2025-03-02 14:21:48 +01:00
fa3d0e8f23 Merge pull request 'Merge pull request 'mastre' (#3) from mastre into 1.0.9' (#5) from 1.0.10 into mastre
Reviewed-on: https://nestict-codelab.ezj3n3.easypanel.host/Nestict_Infotech/MS_Excel_VBA_Reporting_Template/pulls/5
2025-02-28 07:28:46 +01:00
4af67db419 Merge pull request 'mastre' (#3) from mastre into 1.0.9
Reviewed-on: https://nestict-codelab.ezj3n3.easypanel.host/Nestict_Infotech/MS_Excel_VBA_Reporting_Template/pulls/3
2025-02-28 06:17:47 +01:00
0e96b147de Add Manual 2025-02-28 06:08:01 +01:00
2081b52e43 Update README.md 2025-02-28 05:46:41 +01:00
134e072d21 Merge pull request 'Update README.md' (#2) from 1.0.9 into mastre
Reviewed-on: Nestict_Infotech/MS_Excel_VBA_Reporting_Template#2
2025-02-28 05:44:15 +01:00
cef4ee4305 Update README.md 2025-02-28 05:42:55 +01:00
7 changed files with 433 additions and 294 deletions

View File

@ -1,4 +1,3 @@
Attribute VB_Name = "ClearReports"
Sub ClearReportsButton()
Dim ws As Worksheet
Dim wsArr As Variant
@ -34,4 +33,3 @@ Function IsInArray(val As String, arr As Variant) As Boolean
Next i
IsInArray = False
End Function

View File

@ -1,4 +1,3 @@
Attribute VB_Name = "DetailedReport"
Sub GenerateColumnReports()
Dim ws As Worksheet, wsNew As Worksheet
Dim lastRow As Long, columnCol As Long, headerRow As Long

View File

@ -1,4 +1,3 @@
Attribute VB_Name = "FilterAndExtractData"
Sub FilterAndExtractData()
Dim wsData As Worksheet, wsDash As Worksheet
Dim lastRow As Long, headerRow As Long
@ -19,7 +18,7 @@ Sub FilterAndExtractData()
countyFilter = Trim(wsDash.Range("D7").Value) ' County filter
' Clear previous results
wsDash.Range("A10:L35").ClearContents
wsDash.Range("A10:ZL100000").ClearContents
' Set filter range
Set filterRange = wsData.Range(wsData.Cells(headerRow, 1), wsData.Cells(lastRow, wsData.UsedRange.Columns.Count))

145
Manual Normal file
View File

@ -0,0 +1,145 @@
**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.

View File

@ -15,7 +15,7 @@ The **MS Excel VBA Reporting Template** is designed to automate the generation o
- **Error Handling**: Includes basic error handling mechanisms for smoother operation.
## Prerequisites
- Microsoft Excel (2016 or later recommended)
- Microsoft Excel (2010 or later recommended)
- Macros enabled (Ensure that macro settings allow execution of VBA scripts)
- Basic knowledge of VBA (optional but beneficial for customization)
@ -49,5 +49,5 @@ The **MS Excel VBA Reporting Template** is designed to automate the generation o
This template is open-source and can be modified as per your requirements. Ensure proper credits are given when shared publicly.
## Contact
For any issues or custom modifications, feel free to reach out via email at `support@nestict.com.com`.
For any issues or custom modifications, feel free to reach out via email at `support@nestict.com`.

View File

@ -1,4 +1,3 @@
Attribute VB_Name = "ReportPerCounty"
Sub GenerateCountyReports()
Dim ws As Worksheet, wsNew As Worksheet
Dim lastRow As Long, countyCol As Long, headerRow As Long

View File

@ -1,4 +1,3 @@
Attribute VB_Name = "ResetFilters"
Sub ResetFilters()
Dim wsData As Worksheet, wsDash As Worksheet