I'm trying to realize the function below in Excel:
If range("A1:C19") is not blank then Range("D1:F19") locked, vice versa.
If range("A1:C19") and ("D1:F19") are both blank then worksheet is unprotected, range("A1:C19") and ("D1:F19") locked = false.
But when I run the VBA code which is in blue below, then I'm encountering an error indicated "Variant type not match"
Could any one help with this, thanks!
________________________________________________________________

Private Sub Worksheet_Change(ByVal Target As Range)
Call InputLimit
End Sub


Sub InputLimit()
Dim range1 As Range
Dim range2 As Range
Dim Sh As Worksheet
Set Sh = Workbooks("InputLimit").Worksheets("sheet1")
Set range1 = Workbooks("InputLimit").Worksheets("sheet1").Range("A1:C19")
Set range2 = Workbooks("InputLimit").Worksheets("sheet1").Range("D1:F19")
If range1.FormulaR1C1 <> "" And range2.FormulaR1C1 <> "" Then
Sh.Unprotect
range1.Locked = False
range2.Locked = False
ElseIf range1.FormulaR1C1 <> "" Then
range2.Locked = True
Sh.Protect
ElseIf range2.FormulaR1C1 <> "" Then
range1.Locked = True
Sh.Protect
End If
End Sub