ask2tsp
Well-known Member
- Joined
- Feb 18, 2015
- Messages
- 506
- Office Version
- 365
- Platform
- Windows
Hello fellow developers.
I would like you to give feedback on this macro I coded.
There is a practical problem. As you can see in the 2nd sheet below the code is 1214 lines long. So I decided to publish the workbook here
https://1drv.ms/x/s!AmC_nB9H08y-gdk_qY3qh9EzHVMltg
If you prefer the code in a post let me know.
I designed a utility macro that reads all the code modules of all *.xlsm files in a folder and its subfolders.
Next it shows you, in an excel table, all the variables used.
To wet your apetite look at the following 3 excel sheets. Here I selected the folder on my pc where the workbook with this utility is located (the macro looks at its own code)
1. The start sheet to select the top folder and start the macro.
2. the modules sheet shows you the number of code lines found per module per workbook.
3. the Symbol table sheet with all variables found, listed in an excel table so it's easy to filter or reorder the results.
(just the first few lines. Last row=146)
This information can help you in several ways
I'd appreciate all responses.
I would like you to give feedback on this macro I coded.
- educational value: the code contains comment lines to explain various coding techniques. Did it help to understand how some things can be done?
- Working with a dictionary
- Return multiple values from a function
- finding files in a folder and its subfolders
- navigate code modules
- using named ranges
- Ways to call subs in other modules
- writing debug information to a text file
- working with regular expressions
- usefullness: do you think this helps to write higher quality code?
- things to add to make it even more usefull
There is a practical problem. As you can see in the 2nd sheet below the code is 1214 lines long. So I decided to publish the workbook here
https://1drv.ms/x/s!AmC_nB9H08y-gdk_qY3qh9EzHVMltg
If you prefer the code in a post let me know.
I designed a utility macro that reads all the code modules of all *.xlsm files in a folder and its subfolders.
Next it shows you, in an excel table, all the variables used.
To wet your apetite look at the following 3 excel sheets. Here I selected the folder on my pc where the workbook with this utility is located (the macro looks at its own code)
1. The start sheet to select the top folder and start the macro.
2. the modules sheet shows you the number of code lines found per module per workbook.
Excel Workbook | ||||||
---|---|---|---|---|---|---|
B | C | D | E | |||
1 | total 1.214 | |||||
2 | Workbook | Project | Module | Code lines | ||
3 | build symbol table | prSymbols | mContSplit | 224 | ||
4 | build symbol table | prSymbols | mGlobal | 93 | ||
5 | build symbol table | prSymbols | mHelper | 127 | ||
6 | build symbol table | prSymbols | mReport | 84 | ||
7 | build symbol table | prSymbols | mScanFolder | 55 | ||
8 | build symbol table | prSymbols | mSymbolTable | 631 | ||
Sheet |
3. the Symbol table sheet with all variables found, listed in an excel table so it's easy to filter or reorder the results.
Excel Workbook | ||||||||
---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | |||
1 | Symbol | Type | Workbook | Module | Procedure | Scope | ||
2 | arrayClause | String | build symbol table | mSymbolTable | module | |||
3 | ArraySpec | String | build symbol table | mSymbolTable | function tokanize | local | ||
4 | c | Long | build symbol table | mReport | function reportSymboltableToSheet | local | ||
5 | callDepth | Long | build symbol table | mGlobal | project | |||
6 | cCOLON | String Const | build symbol table | mGlobal | project | |||
7 | cCOMMA | String Const | build symbol table | mGlobal | project | |||
8 | cCONST | String Const | build symbol table | mGlobal | project | |||
9 | cDECLARE | String Const | build symbol table | mGlobal | project | |||
10 | cDIM | String Const | build symbol table | mGlobal | project | |||
11 | cDQUOTE | String Const | build symbol table | mGlobal | project | |||
12 | cENUM | String Const | build symbol table | mGlobal | project | |||
13 | cFUNCTION | String Const | build symbol table | mGlobal | project | |||
14 | cGLOBAL | String Const | build symbol table | mGlobal | project | |||
15 | charIndex | Long | build symbol table | mContSplit | function maskCharInsideLiterals | local | ||
16 | closeFlag | Boolean | build symbol table | mSymbolTable | function procesSpecifiedWorkbooks | local | ||
17 | cMASK | String | build symbol table | mGlobal | project | |||
Sheet |
(just the first few lines. Last row=146)
This information can help you in several ways
- Naming conventions: See if all variable names meet agreed naming rules
- Possible scope issues: if a name is used local scope and also module scope, this can lead to unexpected results (bugs) and should be avoided
- consistency: if a variable is declared as different types, some things are unclear and should be investigated
I'd appreciate all responses.