Marsdon
New Member
Hi,
I want to know why does a VBA code written in the last starts running in the beginning and then the First one starts running ?
For eg: I have given the code
I want to know why does a VBA code written in the last starts running in the beginning and then the First one starts running ?
For eg: I have given the code
Code:
Private Sub Worksheet_Calculate()
ActiveSheet.Unprotect Password:="454984djnfui184"
Dim LastRow As Long, c As Range
Application.EnableEvents = False
LastRow = Cells(Cells.Rows.Count, "G").End(xlUp).Row
On Error Resume Next
For Each c In Range("G9:G" & LastRow)
If c.Value = 1 Then
c.EntireRow.Hidden = True
ElseIf c.Value = 0 Then
c.EntireRow.Hidden = False
End If
Next
On Error GoTo 0
Application.EnableEvents = True
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Worksheets("Region Broker ID Report").Range("A:Z").Locked = True
ActiveSheet.Protect AllowUsingPivotTables:=True, Password:="454984djnfui184"
MsgBox "Completed successfully."
End Sub
Last edited by a moderator: