Open the sub in VBA editor. In next row of code after 'Dim', click on left border in editor window - a bullet appears which marks the row where you start debugging the code;
Start the sub. The code stops at bullet;
Press F8 to continue with code row-wise until you get the error message. The row where you got the error is problematic one. You can select any variables or expressions there, right-click on selection, and select Add Watch from dropdown list. When the selection is a valid expression, then the selection is added into Watch window at bottom of VBA Editor window, and the value of selection is displayed there. This allows you to analyze all components for this code row - some of them must be source of error.
|