KC Cat
New Member
- Joined
- Dec 23, 2009
- Messages
- 48
Hello to all,
I am trying to learn how to control how the screen scrolls, or, is scrolled.
I have a workbook that has a worksheet that has several different custom views that I have created. These different custom views hide/unhide columns based on the view. I have form buttons with simple macros that reset the view according to which button is clicked. In each view, the Window / Freeze Panes function has been used to anchor the top 3 rows and left 7 columns. These 7 columns are visible in each view - the only columns that get hidden/unhidden are to the right of this.
The trouble I'm experiencing is that when the user clicks a view button, it is resetting the screen so that row 4 is shown at the top, even if they were looking at row 253, for example. I know why this is happening. It's because that's how the viewed looked when I saved the custom view. My code is selecting the correct row (or cell actually), but it's always off the screen to the bottom (assuming the active cell was scrolled to off the bottom prior to clicking on of the buttons).
What I'd like it to do is apply the custom view they choose, but not have the rows on the screen change (not move, up or down). Or, at least appear as though it had not changed. In other words, they would not notice any change to how the view looks, except for the hiding/unhiding of columns based on the view they choose.
I hope I'm making sense. Here's the code from a typical button macro:
Sub View_Show_Cost_Summary()
Application.ScreenUpdating = False
Dim rowVar As Integer
rowVar = ActiveCell.Row
ActiveWorkbook.CustomViews("Unit / Cost Summary").Show
Range("CurrentViewStatus") = "View = Unit / Cost Summary"
Cells(rowVar, 1).Select
Application.ScreenUpdating = True
End Sub
Thanks in advance for considering my question!
I am trying to learn how to control how the screen scrolls, or, is scrolled.
I have a workbook that has a worksheet that has several different custom views that I have created. These different custom views hide/unhide columns based on the view. I have form buttons with simple macros that reset the view according to which button is clicked. In each view, the Window / Freeze Panes function has been used to anchor the top 3 rows and left 7 columns. These 7 columns are visible in each view - the only columns that get hidden/unhidden are to the right of this.
The trouble I'm experiencing is that when the user clicks a view button, it is resetting the screen so that row 4 is shown at the top, even if they were looking at row 253, for example. I know why this is happening. It's because that's how the viewed looked when I saved the custom view. My code is selecting the correct row (or cell actually), but it's always off the screen to the bottom (assuming the active cell was scrolled to off the bottom prior to clicking on of the buttons).
What I'd like it to do is apply the custom view they choose, but not have the rows on the screen change (not move, up or down). Or, at least appear as though it had not changed. In other words, they would not notice any change to how the view looks, except for the hiding/unhiding of columns based on the view they choose.
I hope I'm making sense. Here's the code from a typical button macro:
Sub View_Show_Cost_Summary()
Application.ScreenUpdating = False
Dim rowVar As Integer
rowVar = ActiveCell.Row
ActiveWorkbook.CustomViews("Unit / Cost Summary").Show
Range("CurrentViewStatus") = "View = Unit / Cost Summary"
Cells(rowVar, 1).Select
Application.ScreenUpdating = True
End Sub
Thanks in advance for considering my question!