Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I created some custom views in my excel document. Normally I use view>custom views>select view method to activate related view. Is it possible to make this job by adding control buttons on excel sheet?

For example there will be a button for each custom view and when I click the button it will show me related view.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

You can do this by enabling the Developer tab in Excel Options, selecting Design Mode, and inserting a Button form control.

When you insert the button control, Excel should open the macro dialog with a macro name like Button1_Click. When you see that, click New on the macro dialog. This will open the event handler for the Button#_Click event in the Visual Basic editor. You'll need to add a line of code to the event handler, so that it looks like this...

Sub Button1_Click()
    ' this is a comment...
    ThisWorkbook.CustomViews("CustomViewName").Show
End Sub

Replace CustomViewName with the actual name of the view you want to show. When you leave design mode and click the button, it should show your custom view. Just add a button and repeat for each view.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.