sharky12345
Well-known Member
- Joined
- Aug 5, 2010
- Messages
- 3,422
- Office Version
- 2016
- Platform
- Windows
I've suddenly started getting an Error 13 - Type Mismatch on this code, which is odd because it's worked fine for weeks;
It's failing on the following lines;
and
Can anyone offer an explanation and ideally a solution?
Code:
Private Sub Worksheet_Activate()
Dim ThisCell2 As Range
Range("K2").Formula = "=TODAY()"
Range("K4:K44").ClearContents
For Each cell In Range("J4:J44")
If cell = "" Then
cell.Offset(0, 1).Value = ""
End If
For Each ThisCell2 In Sheet2.Range("J2:J8")
If InStr(cell.Value, ThisCell2.Value) <> 0 Then
cell.Offset(0, 1).Value = "Available"
End If
Next ThisCell2
For Each ThisCell2 In Sheet2.Range("K2:K21")
If InStr(cell.Value, ThisCell2.Value) <> 0 Then
cell.Offset(0, 1).Value = "Unavailable"
End If
Next ThisCell2
Next
For Each cell In Range("J4:J44")
If cell.Offset(0, 1) = "" Then
Set FoundRange = Sheet2.Range("J2:K22").Find(what:=cell, LookIn:=xlFormulas, lookat:=xlWhole)
If FoundRange Is Nothing Then
cell.Offset(0, 1) = "Unavailable"
End If
End If
Next
End Sub
It's failing on the following lines;
Code:
If cell = "" Then
and
Code:
If InStr(cell.Value, ThisCell2.Value) <> 0 Then
Can anyone offer an explanation and ideally a solution?