'Excel selecting the wrong cell in a specific sheet which have hide/unhide row macros
I have a series of macros with the following format:
If Range("EU_Tick").Value = "True" Then
ActiveSheet.Rows("54:60").EntireRow.Hidden = False
Else:
ActiveSheet.Rows("54:60").EntireRow.Hidden = True
End If
End Sub
This works fine and I am happy with it, however when I am selecting a cell within this sheet it often selects a cell 8/9 cells up or down from the one I am trying to select. I think this starts by selecting where the cell would be if the first 1/2 tick boxes were click and cells were hidden, however this gap between where I try and click and where is selected is then maintained.
If anyone know what is causing this/ how to solve it that would be great!! Thanks
Solution 1:[1]
This is a bug in VBA. Selections count hidden Row numbers even if you cannot access them. The best workaround is the comment of Toddleson.
Another solution is to show all Rows at the beginning with Rows.EntireRow.Hidden = False and hide all relevant rows at once at the end of your macro.
I faced the same problem in MS Project since there is no way to use paths. The solution for MS project is Application.FilterClear and Application.OutlineShowAllTasks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Lukas Schmölzl |
