Please help with Custom Views

S

Souny

Hello all,

I have an Excel file with 4 worksheets. Of the 4 worksheets, I have two
types of custom views ("Comparison" and "Non-Comparison") in each of the 3
worksheets. In the 4th worksheet, I have a command button to change to a
type of custom view in 3 worksheets, and below is a code of the command
button.

Private Sub cmdCustomView()

If Worksheets ("Sheet4").Range("A1").Value = "Comparison" Then

ThisWorkbook.CustomViews("Sheet1 - Comparison").Show
ThisWorkbook.CustomViews("Sheet2 - Comparison").Show
ThisWorkbook.CustomViews("Sheet3 - Comparison").Show

ElseIf Worksheets ("Sheet4").Range("A1").Value = "Non-Comparison" Then

ThisWorkbook.CustomViews("Sheet1 - Non-Comparison").Show
ThisWorkbook.CustomViews("Sheet2 - Non-Comparison").Show
ThisWorkbook.CustomViews("Sheet3 - Non-Comparison").Show

Else

MsgBox "Please select a type of custom view from the list in Cell A1.",
vbCritical, "Custom Views"

End If

End Sub

The problem that I am having is custom views do not stay on all 3
worksheets. For example, if I select "Comparison" in Cell A1 of Sheet4 and
click the button, the custom view "Comparison" happens only on Sheet3 and
does not happen on Sheet1 and Sheet2.

How can I write a code to make sure that the custom view happens on all
three worksheets?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top