EinarOSies
Board Regular
- Joined
- Feb 15, 2021
- Messages
- 61
- Office Version
- 2019
- Platform
- Windows
Please I have been working with a worksheet for sometime. It had been working very fine until a day when working in the specified range it throw the above error. Please when debuging I could not know what is wrong please help!!!
Please the attached is the main sheet
Thanks Einar.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
If Not Intersect(Target, Range("C9:O39")) Is Nothing Then
If Target.Value = "" Then
Range("C9:O39") = ""
Else
On Error GoTo Xit
Application.EnableEvents = False
Range("M6").Value = LastSaveDate
Range("N7").Value = LastSavedBy
Range("I7").Value = ExcelFileSize
Application.EnableEvents = True
Range("M6").Select
Worksheets("PEN 2").Range("M6").Copy
Worksheets("OVERALL TOTAL DETAILS").Range("M6").Value2 = Worksheets("PEN 2").Range("M6").Value2
Sheets("PEN 2").Select
Application.CutCopyMode = False
Range("N7").Select
Worksheets("PEN 2").Range("N7").Copy
Worksheets("OVERALL TOTAL DETAILS").Range("N7").Value2 = Worksheets("PEN 2").Range("N7").Value2
Sheets("PEN 2").Select
Application.CutCopyMode = False
Range("I7").Select
Worksheets("PEN 2").Range("I7").Copy
Worksheets("OVERALL TOTAL DETAILS").Range("I7").Value2 = Worksheets("PEN 2").Range("I7").Value2
Sheets("PEN 2").Select
Application.CutCopyMode = False
End If
End If
Xit:
Application.EnableEvents = True
If Not Intersect(Target, Range("G9:K39")) Is Nothing Then
On Error Resume Next
If Target.Value = "" Then
Range("F6").Value = ""
Else
'Please this is the line the debugger points to
Range("F6").Value = Format(Now, "dddd, d mmmm yyyy hh:mm:ss:ms am/pm")
'Please this is the debugger points to
Range("F6:G6").Select
Worksheets("PEN 2").Range("F6:G6").Copy
Worksheets("OVERALL TOTAL DETAILS").Range("F6").Value2 = Worksheets("PEN 2").Range("F6:G6").Value2
Worksheets("OVERALL TOTAL DETAILS").Range("H6").Value2 = " FROM FROM PEN 2"
Sheets("PEN 2").Select
Application.CutCopyMode = False
End If
End If
If Not Intersect(Target, Range("H9:H39")) Is Nothing Then
On Error Resume Next
If Target.Value = "" Then
Range("F6").Value = ""
Else
Range("F6").Value = Format(Now, "dddd, d mmmm yyyy hh:mm:ss:ms am/pm")
Range("F6:G6").Select
Worksheets("PEN 2").Range("F6:G6").Copy
Worksheets("OVERALL TOTAL DETAILS").Range("F6").Value2 = Worksheets("PEN 2").Range("F6:G6").Value2
Worksheets("OVERALL TOTAL DETAILS").Range("H6").Value2 = " FROM FROM PEN 2"
Sheets("PEN 2").Select
Application.CutCopyMode = False
End If
End If
If Not Intersect(Target, Range("I9:I39")) Is Nothing Then
On Error Resume Next
If Target.Value = "" Then
Range("F6").Value = ""
Else
Range("F6").Value = Format(Now, "dddd, d mmmm yyyy hh:mm:ss:ms am/pm")
Range("F6:G6").Select
Worksheets("PEN 2").Range("F6:G6").Copy
Worksheets("OVERALL TOTAL DETAILS").Range("F6").Value2 = Worksheets("PEN 2").Range("F6:G6").Value2
Worksheets("OVERALL TOTAL DETAILS").Range("H6").Value2 = " FROM FROM PEN 2"
Sheets("PEN 2").Select
Application.CutCopyMode = False
End If
End If
If Not Intersect(Target, Range("J9:J39")) Is Nothing Then
On Error Resume Next
If Target.Value = "" Then
Range("F6").Value = ""
Else
Range("F6").Value = Format(Now, "dddd, d mmmm yyyy hh:mm:ss:ms am/pm")
Range("F6:G6").Select
Worksheets("PEN 2").Range("F6:G6").Copy
Worksheets("OVERALL TOTAL DETAILS").Range("F6").Value2 = Worksheets("PEN 2").Range("F6:G6").Value2
Worksheets("OVERALL TOTAL DETAILS").Range("H6").Value2 = " FROM FROM PEN 2"
Sheets("PEN 2").Select
Application.CutCopyMode = False
End If
End If
If Not Intersect(Target, Range("K9:K39")) Is Nothing Then
On Error Resume Next
If Target.Value = "" Then
Range("F6").Value = ""
Else
Range("F6").Value = Format(Now, "dddd, d mmmm yyyy hh:mm:ss:ms am/pm")
Range("F6:G6").Select
Worksheets("PEN 2").Range("F6:G6").Copy
Worksheets("OVERALL TOTAL DETAILS").Range("F6").Value2 = Worksheets("PEN 2").Range("F6:G6").Value2
Worksheets("OVERALL TOTAL DETAILS").Range("H6").Value2 = " FROM FROM PEN 2"
Sheets("PEN 2").Select
Application.CutCopyMode = False
End If
End If
If Not Intersect(Target, Worksheets("PEN 2").Range("M3")) Is Nothing Then
On Error Resume Next
If Worksheets("PEN 2").Range("G41").Value < 100 And Worksheets("PEN 2").Range("G41").Interior.Color = RGB(248, 203, 173) Then
Application.Speech.Speak "THE TYPE OF BIRD IN PEN TWO is or are" & Worksheets("PEN 2").Range("M3").Text
End If
End If
If Not Intersect(Target, Worksheets("PEN 2").Range("G9:G39")) Is Nothing Then
On Error Resume Next
'Please this is the line the debugger points to
If Worksheets("PEN 2").Range("G41").Value < 100 And Worksheets("PEN 2").Range("G41").Interior.Color = RGB(248, 203, 173) Then
Application.Speech.Speak "THE TOTAL NUMBER OF MORTALITIES IN PEN TWO is " & Worksheets("PEN 2").Range("G41") & "on" & Worksheets("PEN 2").Range("C3") & "in 2020"
End If
End If
'Please this line of code repeat every row from 9 to 39
If Not Intersect(Target, Worksheets("PEN 2").Range("H9:K9")) Is Nothing Then
On Error Resume Next
If Worksheets("PEN 2").Range("H9:K9").Value < 100 And Worksheets("PEN 2").Range("G41").Interior.Color = RGB(244, 176, 132) Then
Application.Speech.Speak "THE TOTAL NUMBER OF CRATES ON" & Worksheets("PEN 2").Range("B9").Text & "IN PEN TWO is " & Worksheets("PEN 2").Range("P9")
End If
End If
Thanks Einar.
Attachments
Last edited: