Search a value in several Excel files
Context
During my first work/study apprenticeship, I used Excel extensively to manage the company's inventory.
As the company had many Excel files, I created this script to search for a value across all of them.
This script saved me time by directly returning the name of the file containing the searched value, instead of having to open each file one by one.
For example, I often had to find the exact serial number of a colleague's PC. Instead of opening all the Excel files one by one, the script would directly give me the file(s) where the value was located.
Step-by-step Script Breakdown
Prompt for the value to search
The script asks the user to enter a value (name, first name, serial number, etc.). It ensures the input is not empty before continuing (~5 seconds).
Execution logging
The script logs who executed it and the exact date/time. This helps with usage tracking (~3 seconds).
Copy Excel files locally
All Excel inventory files are copied to the PC's temporary folder. This allows the script to work locally without altering network files (~10 seconds).
Search the value in all files
The script opens each Excel file, loops through all sheets, and searches for the entered value. If found, it displays the file name and sheet name. If found in multiple files, all are listed (~30 seconds to several minutes depending on the number of files).
Cleanup
After the search is completed, all copied Excel files in the temp folder are deleted to keep the PC clean (~2 seconds).