Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way in VBA to know about variables that aren't being used?

Is there a tool, method or setting in the standard VBA Editor to warn about variables that have been Dim'med, but aren't being used?

like image 215
Lance Roberts Avatar asked Oct 09 '08 19:10

Lance Roberts


People also ask

How do I view variables in Excel VBA?

In the VBA editor go to the View menu and click on Locals Window. Each time F8 is pressed one line of VBA is executed. When the range MyRange is set, you can see that values appear for it in the Locals window. By examining the MyRange object you can drill down to see the values in it.

What is Typename in VBA?

This function returns a string containing the name of the data type that is stored in a variable.

Which window of VBA debugging displays the value of all constants and variables?

The Watch window shows the current values of selected variables or expressions and the current property settings for selected objects. You can use the Watch window to monitor the status of variables and objects as you step through a procedure.

How do you check if a cell has no value in VBA?

With a Worksheet Cell If you wish to test whether a worksheet cell is empty in VBA, you can not use the worksheet function called ISBLANK. In VBA, you must use the ISEMPTY function. In this example, we will test whether cell A1 is empty. If cell A1 is empty, the message "Cell A1 is empty" will be displayed.


1 Answers

MZ-Tools will search through your code and tell you what is not being used. The version for VBA can be found here.

The specific feature in MZ-Tools that performs what you asking about is Review Source Code:

The Review Source Code feature allows you to review the source code to detect some unused declarations (constants, variables, parameters, procedures, etc.).

like image 117
Jon Fournier Avatar answered Sep 23 '22 12:09

Jon Fournier