The Locals window provides easy access to the current value of variables and objects within the scope of the function or subroutine you are running. It is an essential tool to debugging your code and stepping through changes in order to find issues. It also allows you to explore properties you might not have known existed.
Take the following example,
Option Explicit Sub LocalsWindowExample() Dim findMeInLocals As Integer Dim findMEInLocals2 As Range findMeInLocals = 1 Set findMEInLocals2 = ActiveWorkbook.Sheets(1).Range("A1") End Sub
In the VBA Editor, click View --> Locals Window
Then by stepping through the code using F8 after clicking inside the subroutine, we have stopped before getting to assigning findMeinLocals. Below you can see the value is 0 --- and this is what would be used if you never assigned it a value. The range object is 'Nothing'.
If we stop right before the subroutine ends, we can see the final values of the variables.
We can see findMeInLocals with a value of 1 and type of Integer, and FindMeInLocals2 with a type of Range/Range. If we click the + sign we can expand the object and see its properties, such as count or column.