Mikeymike_W
Board Regular
- Joined
- Feb 25, 2016
- Messages
- 171
Hi and thanks for any help you can give.
I have a user who is getting the "cannot run the macro, the macro may not be available in the workbook" error.
I recently updated the workbook so only one user could access it according to their username so i'm assuming its this bit of code (which works fine on my own system).
I would really appreciate any help you can give me on this.
I have a user who is getting the "cannot run the macro, the macro may not be available in the workbook" error.
I recently updated the workbook so only one user could access it according to their username so i'm assuming its this bit of code (which works fine on my own system).
I would really appreciate any help you can give me on this.
VBA Code:
Option Explicit
Option Private Module
Private Sub Users()
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.DisplayAlerts = False
Dim user As String
Dim Users(1) As String
Users(0) = "Mike"
user = Application.UserName
Dim access As Boolean
Dim i As Integer
access = False
For i = 0 To 0
If Users(i) = user Then
access = True
Exit For
End If
Next
If access = False Then
MsgBox ("Sorry, the user """ & user & """ does not have the correct access rights to view this workbook")
ActiveWorkbook.Close
End If
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.DisplayAlerts = True
End Sub