Results 1 to 1 of 1

Macros seem to conflict

Threaded View

Dimond Macros seem to conflict 09-27-2010, 06:09 AM
  1. #1
    Registered User
    Join Date
    09-27-2010
    Location
    York, England
    MS-Off Ver
    Excel 2007
    Posts
    1

    Macros seem to conflict

    I have a sheet for inputting information and I have a button that adds a row at the bottom and a button on each row that deletes that row, including all the buttons on that row.

    The macro for inserting a new row always works and the macro that deletes a row works when the workbook is first opened. The delete macro works after any of the other macros in the workbook are run but if I run the add row macro the delete macro stops working after that.

    Here are the two macros:



    Addrow

    Sub addrow()
    
        Range(ActiveSheet.Buttons(Application.Caller).TopLeftCell.Address).Activate
        ActiveCell.Offset(-1, 0).Select
        ActiveCell.EntireRow.Select
        Selection.Copy
        Range(ActiveSheet.Buttons(Application.Caller).TopLeftCell.Address).Activate
        ActiveCell.EntireRow.Select
        
        Selection.insert Shift:=xlDown
        Application.CutCopyMode = False
       
    End Sub



    Delete Row

    Sub Delete()
    
    Dim shp As Shape
    Dim rng As Range
    
        Range(ActiveSheet.Buttons(Application.Caller).TopLeftCell.Address).Activate
     
        ActiveCell.EntireRow.Select
        
        Set rng = Selection
    
      For Each shp In ActiveSheet.Shapes
            If Not Intersect(shp.TopLeftCell, rng) Is Nothing Then shp.Delete
    
        Next shp
     
        Selection.EntireRow.Delete
    
    End Sub
    After the add row macro has ran the delete macro gets a run time 1004 error and highlights

    If Not Intersect(shp.TopLeftCell, rng) Is Nothing Then


    Can anyone tell me why this is happening and how to stop it, or just a way to work around it if not?
    Last edited by Dimond; 09-27-2010 at 06:18 AM.

Thread Information

Users Browsing this Thread

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

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