Happy Friday!
I'm trying to use a Named Range as x but I'm stuck. Here's the code I have that's giving me a type mismatch error:
If I use a cell instead of a Named Range it works:
I'm trying to use a Named Range as x but I'm stuck. Here's the code I have that's giving me a type mismatch error:
VBA Code:
Sub MarkConfirmed()
Application.EnableEvents = False
Application.ScreenUpdating = False
Application.DisplayAlerts = False
X = Worksheets("Holidays").Range("HolidaysAll").Value
If InStr(Worksheets("Calendar").Range("C" & ActiveCell.Row).Value, ".") Then GoTo SkipConfirm
If InStr(Worksheets("Calendar").Range("C" & ActiveCell.Row).Value, X) Then GoTo SkipConfirm
ActiveSheet.Unprotect
Dim c As Range
For Each c In Selection
If c.Value <> "" Then c.Value = c.Value & "."
Next
'Protect Calendar
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:=False, AllowFormattingCells:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True, AllowInsertingColumns:=True, AllowInsertingRows:=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
SkipConfirm:
Application.EnableEvents = True
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
If I use a cell instead of a Named Range it works:
VBA Code:
X = Worksheets("Holidays").Range("B1").Value