truebluewoman
New Member
- Joined
- Sep 26, 2014
- Messages
- 36
I have a range of cells that if the value is changed to "R", then it should clear the contents of the certain cells to their right. The code actually works, but then I get an error. "RunTime Error '13' Type Mismatch.
When I debug, it appears that the "offending" piece of the code is the third line which is the condition of whether or not the contents to the right should be cleared out. I read on a separate thread that "Target" is a range of cells, so using "Target" in my conditions is wrong. How do I write the condition so I do not get this error? Can anyone help me fix this code? Thank you!
When I debug, it appears that the "offending" piece of the code is the third line which is the condition of whether or not the contents to the right should be cleared out. I read on a separate thread that "Target" is a range of cells, so using "Target" in my conditions is wrong. How do I write the condition so I do not get this error? Can anyone help me fix this code? Thank you!
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("ALL_BED_STATUS")) Is Nothing Then
If Target = "R" Then
ActiveSheet.Range(Target.Offset(, 4), Target.Offset(, 12)).ClearContents
End If
End If
On Error GoTo ErrorHandler
ErrorHandler:
Exit Sub
End Sub