+ Reply to Thread
Results 1 to 3 of 3

Runtime error 13

Hybrid View

Pirvu Vali Runtime error 13 01-08-2019, 02:20 AM
:) Sixthsense :) Re: Runtime error 13 01-08-2019, 02:50 AM
Pirvu Vali Re: Runtime error 13 01-08-2019, 03:19 AM
  1. #1
    Forum Contributor
    Join Date
    08-21-2018
    Location
    Romania
    MS-Off Ver
    2010
    Posts
    178

    Runtime error 13

    Hi ! Why if insert new raw, i have error?
    Attached Files Attached Files

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Runtime error 13

    Because here the Target is not a single cell. It's a range of cells.

    So, change your current code like this...

    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
        If Sh.Name <> "Master" Then
            If Intersect(Target, Range("B:B")) Is Nothing Then Exit Sub
            If Sh.Cells(Target.Row, "B").Value = "x" Then
                Sheets("Master").Range("ZZ1") = Sheets("Master").Range("ZZ1") + 1
                Target.Offset(0, -1) = Sheets("Master").Range("ZZ1")
                Target.EntireRow.Copy Sheets("Master").Cells(Sheets("Master").Rows.Count, "A").End(xlUp).Offset(1, 0)
            ElseIf Sh.Cells(Target.Row, "B").Value = "y" And Sh.Cells(Target.Row, "A").Value <> "" Then
                Sh.Cells(Target.Row, "A").Value = Sh.Cells(Target.Row - 1, "A").Value + 0.1
                Sh.Cells(Target.Row, "B").EntireRow.Copy Sheets("Master").Cells(Sheets("Master").Rows.Count, "A").End(xlUp).Offset(1, 0)
            End If
        End If
    End Sub
    Also use with statement for sh to avoid calling it many times (like the below)

    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
        
    With Sh
        If .Name <> "Master" Then
            If Intersect(Target, Range("B:B")) Is Nothing Then Exit Sub
            If .Cells(Target.Row, "B").Value = "x" Then
                Sheets("Master").Range("ZZ1") = Sheets("Master").Range("ZZ1") + 1
                Target.Offset(0, -1) = Sheets("Master").Range("ZZ1")
                Target.EntireRow.Copy Sheets("Master").Cells(Sheets("Master").Rows.Count, "A").End(xlUp).Offset(1, 0)
            ElseIf Sh.Cells(Target.Row, "B").Value = "y" And Sh.Cells(Target.Row, "A").Value <> "" Then
                .Cells(Target.Row, "A").Value = .Cells(Target.Row - 1, "A").Value + 0.1
                .Cells(Target.Row, "B").EntireRow.Copy Sheets("Master").Cells(Sheets("Master").Rows.Count, "A").End(xlUp).Offset(1, 0)
            End If
        End If
    End With
    
    End Sub
    Last edited by :) Sixthsense :); 01-08-2019 at 02:53 AM.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Contributor
    Join Date
    08-21-2018
    Location
    Romania
    MS-Off Ver
    2010
    Posts
    178

    Re: Runtime error 13

    thank you very much

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Mac throwing error - Runtime Error 429 - ActiveX Component Can't Create Object
    By harman83 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 11-28-2018, 11:04 PM
  2. Runtime error 1004 & runtime error 424
    By MrWhiskey in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-29-2017, 08:57 AM
  3. Runtime error '1004': Paste special method of range class error.
    By Daryl Zer0 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-05-2014, 01:44 AM
  4. [SOLVED] VBA Error: Runtime Error 1004: AutoFilter method of Range class failed
    By jl22stac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2013, 07:27 PM
  5. [SOLVED] Range error in code, runs alone but not inside my full program, giving runtime error 1004
    By charizzardd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-23-2012, 03:34 PM
  6. runtime error 3265 error in a VBA Query to pull info from ERP Database
    By NBVC in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-12-2010, 03:59 PM
  7. Excel xmlHTTP object error message - system/runtime error
    By Porky2007 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-23-2007, 09:36 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1