HI all,
This should be really easy but i am very new to VBA, I am looking at line 9. What i would like this to be is the max of this number or 57, something like
TopRow = Max(57, .Range("K13").Value / 3)
Here is my code, Thanks for all of your help
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim NewRange As String, _
TopRow As Long
If EditMode = ActiveSheet.Name Then Exit Sub
With ActiveSheet
If .Range("I8").Value <> "" And .Range("I9").Value <> "" Then
TopRow = .Range("K13").Value / 3
NewRange = Cells(56 - TopRow, "C").Address(0, 0) & ":C56"
.Unprotect "viceroy11"
.Cells.Locked = True
.Cells.Interior.ColorIndex = xlColorIndexNone
.Range("I8:I11").Locked = False
.Range("I13:I15").Locked = False
.Range("N28:O53").Locked = False
.Range("I20").Locked = False
.Range("Q37").Locked = False
.Range(NewRange).Interior.ColorIndex = 6
.Range(NewRange).Locked = False
.Protect "viceroy11"
.EnableSelection = xlUnlockedCells
.Protect
EditMode = ActiveSheet.Name
End If
End With
exit_routine:
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Bookmarks