You can simply add another event to the function, after the loop - Set "Layer 3" visible
Another solution would be renaming all layers that you want to change visibility like this: L1, L2, L3, L4...
And change your code: For ""=1 to 20 : Set layer "L"&loopindex invisible