Hey I’ve got a project I have done and due to the file being quite large I was in search of some way to figure out the number of / type of screws within the project. In my search I found another user had created a macro to search a part(I think?) for the number of screw needed for the part and somehow he could have the type of screw / length of the screw displaying using cosmetic threads. I’ve litteraly just started using Macros for Solidworks today, though I have reasonable experience using ExcelVBA.
Look into using BOMs instead and you should be able to find the desired results.
Agreed with @Gupta9665 . There is no need to reinvent the wheel.