+ Reply to Thread
Results 1 to 5 of 5

Removing excel rows with a command button

  1. #1
    Forum Contributor
    Join Date
    08-10-2017
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    141

    Removing excel rows with a command button

    Hi guys,

    Just wondering is it possible to remove certain a particular row using a command button

    You will see in the file attached I have created a + button to add a row at the bottom of my transport sheet just above the notes row, Is this possible to be done for a Minus button and remove the last row above notes?

    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: Removing excel rows with a command button

    try the code below

    Private Sub CommandButton2_Click()
    Dim rrow As Long
    rrow = Sheet1.Cells(Sheet1.Rows.Count, "B").End(xlUp).Row
    rrow = rrow - 1
    Sheet1.Rows(rrow).Delete Shift:=xlShiftUp
    End Sub

  3. #3
    Forum Contributor
    Join Date
    08-10-2017
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    141

    Re: Removing excel rows with a command button

    Hi torachan,

    That code works well,

    One question with it however, When i protect the worksheet it comes up with a runtime error 1004

    When the sheet is not protected works fine

    Is it possible for the minus function to work?

    Thanks in advance

  4. #4
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: Removing excel rows with a command button

    Try this instead
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    08-10-2017
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    141

    Re: Removing excel rows with a command button

    works a treat A++++

    many thanks

+ 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. Replies: 2
    Last Post: 02-02-2016, 10:27 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. Print last x Number of rows in Excel from Command Button
    By Nu2Java in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-17-2012, 11:31 AM
  4. Command Button to unhide rows
    By earl54dink in forum Excel - New Users/Basics
    Replies: 6
    Last Post: 04-30-2008, 12:11 PM
  5. Hide Command Button & Rows
    By LaForgeOZ in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-01-2008, 08:08 PM
  6. Replies: 1
    Last Post: 09-17-2007, 09:57 PM
  7. Through a command button hiding rows
    By Saz in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-07-2006, 11:29 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