Run-time error'1004'@ Application-defined or object-defined error

EinarOSies

Board Regular
Joined
Feb 15, 2021
Messages
61
Office Version
  1. 2019
Platform
  1. 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!!!

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
Please the attached is the main sheet

Thanks Einar.
 

Attachments

  • problem.JPG
    problem.JPG
    254.8 KB · Views: 4
Last edited:

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
The error appears in cells G9 to K39. To be specific.
Thanks
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,851
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top