Disclaimer in VBA

jraymond1984

New Member
Joined
Apr 29, 2011
Messages
10
Hi

I have the following VBA code for a disclaimer in my spreadsheet. At the moment what it does is an icon box pops up when you open the spreadsheet, and if you click 'Yes' all the other tabs to the spreadsheet open, if you click 'No' then you cannot access the spreadsheet.

What I am trying to do instead is have my spreadsheet such that when you open the spreadsheet, only the disclaimer page opens, and you have to click on a button (i.e. linked to the macro) which is essentially the 'Accept' the disclaimer, following which all the remaining tabs on the spreadsheet will now appear.

If you are able to please help me change the code, it would be much appreciated.

Many thanks in advance,

Jonathan



Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim i As Integer, j As Integer

j = ActiveWorkbook.Sheets.Count

For i = 2 To j
ActiveWorkbook.Sheets(i).Visible = xlSheetVeryHidden
Next i

ActiveWorkbook.Save

End Sub

Private Sub Workbook_Open()
Dim i As Integer, j As Integer

j = ActiveWorkbook.Sheets.Count

MSG1 = MsgBox("Please click yes to confirm you adhere to the Disclaimer", vbYesNo, "Disclaimer")

If MSG1 = vbYes Then
For i = 2 To j
ActiveWorkbook.Sheets(i).Visible = True
Next i
Else
ActiveWorkbook.Close
End If

End Sub
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Where is your disclaimer on? Is it on your Sheet1?

If so, go to Developer Ribbon -> Insert -> ActiveX Control Command Button ->
Draw on the worksheet -> Double click the button

copy + paste this code in
Code:
Dim i As Integer
For i = 2 To ActiveWorkbook.Sheets.Count
    ActiveWorkbook.Sheets(i).Visible = True
Next i

Then Replace your caption of your commandbutton to Accept and play with the properties of it if you want.

I hope this helped.
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,740
Members
452,940
Latest member
Lawrenceiow

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top