S
Sean
I am trying to have A1 at Top left corner of each sheet when I open a
file. The code below is what I am using although it doesn't see to
work on all sheets. There is other stuff this code does, but I'll post
the full code just in case something is causing not all sheets to goto
A1
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Dim myArray As Variant
Dim arName As String
Dim ws As Worksheet
arName = "MyUsers"
myArray = ThisWorkbook.Names(arName).RefersToRange.Value
With Application
If IsError(.Application.Match(.UserName, myArray, 0)) Then
MsgBox "You are NOT Permitted to access this File " & vbCr & _
"" & vbCr & _
"Please Contact Joe Bloggs at " & vbCr & _
"" & vbCr & _
"ABC Group +00999 1 123456"
Application.DisplayAlerts = False
ThisWorkbook.Close False
Else
For Each ws In Worksheets
ws.Visible = True
Next
Worksheets("DontGo").Visible = False
Worksheets("Masters").Visible = xlVeryHidden
For Each ws In ThisWorkbook.Worksheets
If ws.Visible = xlSheetVisible Then
ws.Select False
End If
Next
Application.Goto Range("A1"), True
Sheets("Sum").Activate
Application.DisplayAlerts = True
End If
End With
End Sub
file. The code below is what I am using although it doesn't see to
work on all sheets. There is other stuff this code does, but I'll post
the full code just in case something is causing not all sheets to goto
A1
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Dim myArray As Variant
Dim arName As String
Dim ws As Worksheet
arName = "MyUsers"
myArray = ThisWorkbook.Names(arName).RefersToRange.Value
With Application
If IsError(.Application.Match(.UserName, myArray, 0)) Then
MsgBox "You are NOT Permitted to access this File " & vbCr & _
"" & vbCr & _
"Please Contact Joe Bloggs at " & vbCr & _
"" & vbCr & _
"ABC Group +00999 1 123456"
Application.DisplayAlerts = False
ThisWorkbook.Close False
Else
For Each ws In Worksheets
ws.Visible = True
Next
Worksheets("DontGo").Visible = False
Worksheets("Masters").Visible = xlVeryHidden
For Each ws In ThisWorkbook.Worksheets
If ws.Visible = xlSheetVisible Then
ws.Select False
End If
Next
Application.Goto Range("A1"), True
Sheets("Sum").Activate
Application.DisplayAlerts = True
End If
End With
End Sub