I created a new project, added a StatusBar control, set the AutoSize to "spring" on all the panels (not sure whether this had any effect), inserted a bunch of panels so the code could run, then pasted your code. It appears to work just fine.
What problem do you have with it? As I said, we need something more specific than "doesn't work". For all I know, "doesn't work" could mean anything from "I don't like the colour very much" to "it burnt my house down and killed the dog".
By the way, after pasting your code I commented out these two lines, as they don't do anything...
-
Dim panels As Panel
-
Set panels = Nothing
-
Here's a snapshot of the results I got...