I have the following code Written to open my calendar whenever someone clicks on the targeted cells.
However, I get a Method Range of Object worksheet failed
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rng1 As Range, rng2 As Range, rng3 As Range
Set rng1 = Range("B2:k2,B4:K4,B6:K6,B8:K8,B10:K10,B12:K12,B14:K14,B16:K16,B18:K18,B20:K20,B22:K22,B24:K24,B26:K26, B28:K28, b30:K30, B32:K32, B34:K34, B36:K36, B38:K38, B40:K40, B42:K42, B44:K44, B46:K46, B48:K48, B50:K50, B52:K52, B54:K54, B56:K56, B58:K58")
Set rng2 = Range("B60:k60,B62:K62,B64:K64,B66:K66,B68:K68,B70:K70,B72:K72,B74:K74,B76:K76,B78:K78,B80:K80,B82:K82,B84:K84, B86:K86, b88:K88, B90:K90, B92:K92, B94:K94, B96:K96, B98:K98, B100:K100, B102:K102, B104:K104, B106:K106, B108:K108, B110:K110, B112:K112, B114:K114, B116:K116")
Set rng3 = Range("B118:k118,B120:K120,B122:K122,B124:K124,B126:K126,B128:K128,B130:K130,B132:K132,B134:K134,B136:K136,B138:K138,B140:K140,B142:K142, B144:K144, b146:K146, B148:K148, B150:K150, B152:K152, B154:K154, B156:K156, B158:K158, B160:K160, B162:K162, B164:K164, B166:K166, B168:K168, B170:K170, B172:K172, B174:K174")
If Application.Intersect(Target, rng1) Is Nothing Then
Call OpenCalendar
If Application.Intersect(Target, rng2) Is Nothing Then
Call OpenCalendar
If Application.Intersect(Target, rng3) Is Nothing Then
Call OpenCalendar
End If
End If
End If
End Sub
I have also used:
If Application.Intersect(Target, Union(rng1, rng2, rng3)) Is Nothing Then
call opencalendar
but this does not work either.
Any help would be greatly appreciated.
However, I get a Method Range of Object worksheet failed
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rng1 As Range, rng2 As Range, rng3 As Range
Set rng1 = Range("B2:k2,B4:K4,B6:K6,B8:K8,B10:K10,B12:K12,B14:K14,B16:K16,B18:K18,B20:K20,B22:K22,B24:K24,B26:K26, B28:K28, b30:K30, B32:K32, B34:K34, B36:K36, B38:K38, B40:K40, B42:K42, B44:K44, B46:K46, B48:K48, B50:K50, B52:K52, B54:K54, B56:K56, B58:K58")
Set rng2 = Range("B60:k60,B62:K62,B64:K64,B66:K66,B68:K68,B70:K70,B72:K72,B74:K74,B76:K76,B78:K78,B80:K80,B82:K82,B84:K84, B86:K86, b88:K88, B90:K90, B92:K92, B94:K94, B96:K96, B98:K98, B100:K100, B102:K102, B104:K104, B106:K106, B108:K108, B110:K110, B112:K112, B114:K114, B116:K116")
Set rng3 = Range("B118:k118,B120:K120,B122:K122,B124:K124,B126:K126,B128:K128,B130:K130,B132:K132,B134:K134,B136:K136,B138:K138,B140:K140,B142:K142, B144:K144, b146:K146, B148:K148, B150:K150, B152:K152, B154:K154, B156:K156, B158:K158, B160:K160, B162:K162, B164:K164, B166:K166, B168:K168, B170:K170, B172:K172, B174:K174")
If Application.Intersect(Target, rng1) Is Nothing Then
Call OpenCalendar
If Application.Intersect(Target, rng2) Is Nothing Then
Call OpenCalendar
If Application.Intersect(Target, rng3) Is Nothing Then
Call OpenCalendar
End If
End If
End If
End Sub
I have also used:
If Application.Intersect(Target, Union(rng1, rng2, rng3)) Is Nothing Then
call opencalendar
but this does not work either.
Any help would be greatly appreciated.