Private Sub Worksheet_Activate()
Dim wSheet As Worksheet
Dim calcState As Long, scrUpdateState As Long
Dim Status As String, NxRw As Long
calcState = Application.Calculation
Application.Calculation = xlCalculationManual
scrUpdateState = Application.ScreenUpdating
Application.ScreenUpdating = False
With Me
.Cells(1, 1).Name = "Index"
.Cells.ClearContents
.Cells(2, 2) = "PLANNED"
.Cells(2, 4) = "IB-BUILD"
.Cells(2, 6) = "COMPLETE"
End With
For Each wSheet In Worksheets
If wSheet.Name <> Me.Name And wSheet.Range("Y2") <> "" Then
Status = wSheet.Range("Y2")
Select Case Status
Case "PLANNED"
NxRw = Me.Cells(Rows.Count, "B").End(xlUp).Row + 1
With wSheet
.Range("A1").Name = "Start_" & wSheet.Index
.Hyperlinks.Add Anchor:=.Range("A1"), Address:="", _
SubAddress:="Index", TextToDisplay:="Back to Index"
End With
Me.Hyperlinks.Add Anchor:=Me.Cells(NxRw, "B"), Address:="", _
SubAddress:="Start_" & wSheet.Index, TextToDisplay:=wSheet.Name
Case "IB-BUILD"
NxRw = Me.Cells(Rows.Count, "D").End(xlUp).Row + 1
With wSheet
.Range("A1").Name = "Start_" & wSheet.Index
.Hyperlinks.Add Anchor:=.Range("A1"), Address:="", _
SubAddress:="Index", TextToDisplay:="Back to Index"
End With
Me.Hyperlinks.Add Anchor:=Me.Cells(NxRw, "D"), Address:="", _
SubAddress:="Start_" & wSheet.Index, TextToDisplay:=wSheet.Name
Case "COMPLETE"
NxRw = Me.Cells(Rows.Count, "F").End(xlUp).Row + 1
With wSheet
.Range("A1").Name = "Start_" & wSheet.Index
.Hyperlinks.Add Anchor:=.Range("A1"), Address:="", _
SubAddress:="Index", TextToDisplay:="Back to Index"
End With
Me.Hyperlinks.Add Anchor:=Me.Cells(NxRw, "F"), Address:="", _
SubAddress:="Start_" & wSheet.Index, TextToDisplay:=wSheet.Name
Case Else
MsgBox "There is a problem with worksheet " & wSheet.Name & " please check the Status cell on that sheet."
End Select
End If
Next wSheet
Me.UsedRange.Columns.AutoFit
Application.Calculation = calcState
Application.ScreenUpdating = scrUpdateState
End Sub