Search code examples
vbaexcelscrollvertical-scrolling

Excel stops scrolling after a Copy command


I have a set of data entries in the 2nd Worksheet of my Workbook, which are part of a list using Filters. Using VBA I have created a button that when clicked, opens a Userform which lets the user enter their desired data selection to be copied from the 2nd Worksheet to the 1st Worksheet. This is done by having the user checking 1 out of 8 possible OptionButtons and then having the user select 1 of 5 possible options from a ComboBox. All is well and every possible combination in the Userform inputs leads to the correct data being copied from the 2nd Worksheet in to the 1st Worksheet. However, after a successful copy, I am unable to scroll using my scroll wheel in my 1st Worksheet. The "square" moves in the scrollbar when scrolling with the scroll wheel, however the worksheet does not move. The main differences between the two Worksheets are that in the 1st Worksheet, no filters are present and that the copied selection is always less data then the source data, however this isn't to big of a difference (source data in 2nd worksheet is about 300 rows, smallest copy possibility is around 12 rows). I've searched and tried the following solutions, with the accompanying results.

  1. Unfreeze Panes; One solution suggested was to unfreeze panes as Excel would possibly freeze all rows after the copy. However, when checked there was no "Unfreeze" option, indicating that I had no frozen panes to begin with. Also, when I clicked any of the three "Freeze" options, thinking I would try to manually "Freeze" and then "Unfreeze" to resolve the issue, Excel would stop working, giving me the "Not Responding" in the title bar and needed to be shut down/restarted.

  2. Select Objects; Another suggestion was that Excel would have the "Select Objects" checked in the "Find & Select" portion of the "Home" tab. When un-checking this, the issue should be resolved. However, it wasn't checked to begin with. Checking it and then un-checking it did not resolve the problem.

  3. Switch Worksheets; When I manually click the 2nd Worksheet after a copy command and then click back to the 1st Worksheet, the problem is resolved and I can use the scroll wheel again. However, I intend to use this Workbook a lot and having to constantly click back and forth is going to be a pain. So this isn't really a solution, more of a work around.

  4. Dragging; Another work around I have found is that clicking and then dragging the "square" in the scrollbar does move the worksheet around. However, this is again just a temporarily fix.

One more thing that may be useful to mention. In both Worksheet 1 & 2 I am using collapsible columns. Worksheet 2 also contains collapsible rows, where Worksheet 1 does not.


Solution

  • Okay, so on a whim I tried to enter the following 2 lines of code to the end of the sub

    ThisWorkbook.Sheets("Overview").Activate      'Activates the 2nd Worksheet
    ThisWorkbook.Sheets("Selection").Activate     'Activates the 1st Worksheet
    

    This mimics the manually triggering of switching Worksheets. And it resolved the problem. Still don't understand why the problem occurred but it's solved anyway.