Results 1 to 4 of 4

Help on VBA code to delete a row in more than one table from a single command button

Threaded View

  1. #1
    Registered User
    Join Date
    07-13-2017
    Location
    Newcastle, UK
    MS-Off Ver
    2010
    Posts
    10

    Help on VBA code to delete a row in more than one table from a single command button

    Hi All,

    i am very new to excel and VBA/Macro. Yesterday I was given some excellent help with defining some code to create a command button that would delete and insert a row into a table that I had defined. I now want to take this one step further and use the same command button to insert/delete rows from another table I have created in the same sheet.

    I have manged to get it working for an insert but not for the delete more through luck than logic. If have attached the code (apologies if I am not supposed to do this). If anyone could help that would be ideal.

    Sub InsertRow()
    With Intersect(ActiveCell.EntireRow, Range("Table1"))
    With Intersect(ActiveCell.EntireRow, Range("Table3"))
      ActiveSheet.Unprotect
        .Copy
        .Offset(1).Insert
        Application.CutCopyMode = False
        On Error Resume Next
        .Offset(1).SpecialCells(xlCellTypeConstants).ClearContents
        On Error GoTo 0
        ActiveSheet.Protect
      End With
      End With
    End Sub
    Sub Delete_Row()
     With Intersect(ActiveCell.EntireRow, Range("Table1"))
        ActiveSheet.Unprotect
        Intersect(ActiveCell.EntireRow, Range("Table1")).Delete Shift:=xlUp
        ActiveSheet.Protect
     End With
    End Sub
    Regards Graham
    Last edited by alansidman; 07-21-2017 at 07:54 AM. Reason: missed some code off original

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA Code does not respond to a single click of command button
    By Buddy8 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-18-2016, 06:00 PM
  2. VBA code to create command button. Print all sheets then delete command button.
    By Declamatory in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-15-2015, 05:18 PM
  3. [SOLVED] Delete Entire Row based on single cell value using VBA command Button
    By rain4uu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-07-2014, 12:53 PM
  4. [SOLVED] Userform: Code for DELETE on a command button
    By Gal403 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-25-2014, 01:28 AM
  5. Create a command button with code with a command button
    By jakara in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2013, 01:28 PM
  6. Code for a master command button to change the backcolor of multiple command buttons?
    By panttherm5 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2012, 10:11 PM
  7. Command Button Code to Delete Unprotected Cells Only
    By macky1730 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-01-2011, 04:30 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