J
JMay
On a particular WS I have to custom views set up. I want to put a
button
on the sheet to Toggle between the 2 views.
Off google I found the below (from Chip Pearson):
Sub ToggleViews()
Static ViewName As String
If ViewName = "View1" Then
ThisWorkbook.CustomViews("View2").Show
ViewName = "View2"
Else
ThisWorkbook.CustomViews("View1").Show
ViewName = "View1"
End If
End Sub
I substituted as follows:
Sub ToggleViews()
Static ViewName As String
If ViewName = "Monthly Budget" Then
ThisWorkbook.CustomViews("Compare Budget To Actual").Show
ViewName = "Compare Budget To Actual"
Else
ThisWorkbook.CustomViews("Monthly Budget").Show
ViewName = "Monthly Budget"
End If
End Sub
My revised code is not working - as a matter of fact when I step
thru it using the F8 Key - as I begin the sheet is currently in the
"Monthly Budget" View.. Perhaps because ViewName is undefined my
cursor jumps to the Else line and then the line following. As soon
as I F8 on this line - the code jumps to an unrelated UDF Function
Higher up in the Standard module:
Function FilterCriteria(Rng As Range) As String
'By Stephen Bullen
What's going on here? My Sub toggleViews I have in a standard module,
right?
button
on the sheet to Toggle between the 2 views.
Off google I found the below (from Chip Pearson):
Sub ToggleViews()
Static ViewName As String
If ViewName = "View1" Then
ThisWorkbook.CustomViews("View2").Show
ViewName = "View2"
Else
ThisWorkbook.CustomViews("View1").Show
ViewName = "View1"
End If
End Sub
I substituted as follows:
Sub ToggleViews()
Static ViewName As String
If ViewName = "Monthly Budget" Then
ThisWorkbook.CustomViews("Compare Budget To Actual").Show
ViewName = "Compare Budget To Actual"
Else
ThisWorkbook.CustomViews("Monthly Budget").Show
ViewName = "Monthly Budget"
End If
End Sub
My revised code is not working - as a matter of fact when I step
thru it using the F8 Key - as I begin the sheet is currently in the
"Monthly Budget" View.. Perhaps because ViewName is undefined my
cursor jumps to the Else line and then the line following. As soon
as I F8 on this line - the code jumps to an unrelated UDF Function
Higher up in the Standard module:
Function FilterCriteria(Rng As Range) As String
'By Stephen Bullen
What's going on here? My Sub toggleViews I have in a standard module,
right?