I have a Worksheet_Change
event, currently at the Sheet Module Level
. The problem is that I want to be able to clear this sheet at times. However, when
I believe you are using xl2007+?
The Target.Cells.Count
is a Long
value and hence when you select the entire worksheet the .Count
is too small to hold the result.
Replace line
If Target.Count = 1 Then
with
If Target.Cells.CountLarge = 1 Then
You might also want to see this since you are using Worksheet_Change
EDIT:
Two other things
1)
You can also replace this line
If Target = Range("A4") Then
with
If Not Intersect(Target, Range("A4")) Is Nothing Then
2)
This line
If InStr(LCase(Target.Value), "loaded") <> 0 Then
can also be written as
If InStr(1, Target.Value, "loaded", vbTextCompare) Then