0

I'm debugging my VBA EXCEL macro. I have several multidimensional arrays that I monitor at breakpoints in the local window of the debugger. In the local window, each array is folded and on the right side of the array is a small "+" where you can unfold each dimension of the array individually. In my example the dimension is 10 x 3 and I need to click 10 times to unfold the complete array. At the next breakpoints (leaving and entering the subroutine), the array is folded again and I have to click ten times again.

Is there a smarter way to unfold all dimensions of an array or leave the array unfolded?

I've tried: ESC, Enter, Return, +, -, *, / and multiple F keys. I tried to mark multiple dimensions but you can only mark one row and not multiple rows of an array.

musbach
  • 558
  • 1
  • 9
  • 29
  • I’m voting to close this question because its a programming issue – freeflow Jul 10 '22 at 11:37
  • 1
    Where should I ask this question? – musbach Jul 10 '22 at 12:15
  • That should be **NOT** a programming issue. – freeflow Jul 10 '22 at 13:03
  • You could try vbforums – freeflow Jul 10 '22 at 13:04
  • 1
    I've asked some debugger questions in the past like: "Make doxygen document the #ifdef parts too". It is about handling the debugger and not programming. Where do you draw the line? – musbach Jul 10 '22 at 13:21
  • 1
    I do not think there are shortcuts to deal with it. The faster way I found, was to select the variable and press `Enter`. Then, press down arrow followed by `Enter` for each expanded element. It is only possible to colaps all, using `Shift + F10`. It will launch the shortcut menu where from to click `Collapse Parent`. But not useful in case of your problem... – FaneDuru Jul 10 '22 at 15:07

1 Answers1

1

There's no way of automatically expanding everything in the Locals Window, but if you're doing a lot of debugging and don't have too many arrays that are too large, you can simulate a fully expanded Locals Window using the Watches Window instead.

  • Display the Watches Window through the View menu.
  • Right click on your code to Add Watch... (this can be done even while in Break mode)
  • Add one element of one array at a time.

Demo

It might seem a little tedious, but you can easily add a few dozen elements in less than a minute and they will persist while you have the workbook open (even if you close the VBA editor or run macros in other projects). You can also be more selective about which elements you monitor.

Watches can be any VBA expression, so you could even generate strings that display the arrays in a more compact format:

enter image description here

If you need to reinstate watches regularly, there's a clunky option for adding them automatically: How can I save VBA watches manually or add them via code?

Michael
  • 4,563
  • 2
  • 11
  • 25