VBA code needed please

J

john

Afternoon All

Hope all are well

I have a worksheet that I want two views for, one a coordinator and two an analysts view. I've setup radio buttons to toggle this but when the radio buttons input cell is 2 in !A3!Sheet2 then on sheet named "Corra Logsheet" rows A2 and A5 are hidden and the filter on E6 is set to filter "Yes". Obviously if the radio buttons linked cell as above reads 1 then it must revert back

Is this possible please? And if so does anyone have any ideas

Many Thank

John
 
D

Dave Peterson

There's a feature built into excel called customviews.

View|custom views (from the worksheet menubar is how you access it).

Create a custom view named "coordinatorOPT" that is the "normal" view.
Create another custom view named "AnalystOPT" that has everything hidden
(including the autofilter stuff).

I used the radio buttons (Optionbuttons) from the Forms toolbar.

Then I named each button after the custom view.
coordinatorOPT
analystOPT

Then I assigned this macro to both:

Option Explicit
Sub OptionBTN_click()
ThisWorkbook.CustomViews(Application.Caller).Show
End Sub

If the names don't match, this won't work--so be careful when you do it.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Short course:
Open your workbook
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like: VBAProject (yourfilename.xls)

right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side

Paste the code in there.

Now go back to excel and test it out.
 
Top