Can you tell me what's wrong with my codes? I have macros on my other protected sheets and they are working fine. I have summary sheet named Index positioned at the very last and that's where I am getting the error whenever I protect it. Here are the codes:
Whenever I debug the codes, the line .Columns(1).ClearContents is being highlighted. Did I miss anything?
Thanks,
Code:
Private Sub Worksheet_Activate()
Dim wSheet As Worksheet
Dim n As Integer
Dim calcState As Long, scrUpdateState As Long
calcState = Application.Calculation
Application.Calculation = xlCalculationManual
scrUpdateState = Application.ScreenUpdating
Application.ScreenUpdating = False
n = 1
With Me
.Columns(1).ClearContents
.Cells(1, 1) = "Date"
.Cells(1, 1).Name = "Index"
End With
For Each wSheet In Worksheets
If wSheet.Name <> Me.Name Then
n = n + 1
With wSheet
.Range("B1").Name = "Start_" & wSheet.Index
.Hyperlinks.Add anchor:=.Range("B1"), Address:="", _
SubAddress:="Index", TextToDisplay:="Back to Index"
End With
Me.Hyperlinks.Add anchor:=Me.Cells(n, 1), Address:="", _
SubAddress:="Start_" & wSheet.Index, TextToDisplay:=wSheet.Name
End If
Next wSheet
Application.Calculation = calcState
Application.ScreenUpdating = scrUpdateState
End Sub
Whenever I debug the codes, the line .Columns(1).ClearContents is being highlighted. Did I miss anything?
Thanks,
Last edited: