+ Reply to Thread
Results 1 to 16 of 16

VBA Macro Button to delete entire row

  1. #1
    Registered User
    Join Date
    04-22-2018
    Location
    orlando
    MS-Off Ver
    2013
    Posts
    33

    VBA Macro Button to delete entire row

    Hey Guys,

    I'm fairly new to VBA and im trying to find code to copy an entire row, paste it to another worksheet, then delete the entire row where the button is; including the button. But I want to have a button at the end of each row. I got the copy and paste down, but im having trouble with the command to delete only the row that the button is in. I'm trying to select the cell that the top left corner of the button is in, but I cant get it to work. This is what I have.

    Please Login or Register  to view this content.
    It would also be great if I could create a new row with the formulas from the other rows, so I don't have to have a 100 blank rows. Thanks in advance!
    Last edited by alansidman; 08-04-2018 at 05:20 PM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,865

    Re: VBA Macro Button to delete entire row

    Code Tags Added
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: VBA Macro Button to delete entire row

    Sorry Freind


    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  4. #4
    Registered User
    Join Date
    04-22-2018
    Location
    orlando
    MS-Off Ver
    2013
    Posts
    33

    Re: VBA Macro Button to delete entire row

    Thank You, I was wondering why it looked different than everyone else's. My first VBA question. I will comply in all further questions. Thanks for fixing it for me!

  5. #5
    Registered User
    Join Date
    04-22-2018
    Location
    orlando
    MS-Off Ver
    2013
    Posts
    33

    Re: VBA Macro Button to delete entire row

    Thank You, I was wondering why it looked different than everyone else's. My first VBA question. I will comply in all further questions.

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: VBA Macro Button to delete entire row

    Thanks Alan

    I can now reply.


    1. Why would you want a button on each row? You can have a macro run on :-

    Double Click
    Right Click
    Pressing ctrl and a key.

    Dealing with numerous button is a pain and frankly pointless

  7. #7
    Registered User
    Join Date
    04-22-2018
    Location
    orlando
    MS-Off Ver
    2013
    Posts
    33

    Re: VBA Macro Button to delete entire row

    Please explain. I have 10 rows that have projects in them. Once that project is complete, I want to be able to catalogue it in the Completed projects worksheet, and then delete that row. But the projects are completed at different times. Also information will be added to new rows all the time. I don't understand what :- means, maybe that's why im having trouble. Thanks!

  8. #8
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: VBA Macro Button to delete entire row

    Ok

    I created this Macro:-

    Please Login or Register  to view this content.
    I can run this selecting Developer, Macros, Select Macro1 and then run.

    However if I select Developer, Macros,Macro1 and then options, I can enter a letter like "d" into the shortcut box.

    Now if i hold down the ctrl key and press "d" the Macro will run.

    ****************************************************************************************************************************

    If I right click on the sheet name at the bottom of excel and select view code.

    A module opens.

    If I paste this code in that module and close it.

    Please Login or Register  to view this content.

    My Macro will also run if I doubleclick or right click.

  9. #9
    Registered User
    Join Date
    04-22-2018
    Location
    orlando
    MS-Off Ver
    2013
    Posts
    33

    Re: VBA Macro Button to delete entire row

    Thanks so much for this, but I'm making this for other people to use, so I'm trying to not use Cntl click. This is going to be a shared, active sheet. I would love the user to be able to just click a button, or a word, and have that row do what I want. I've attached an example. Its still crude because I'm trying to figure this part out. Thanks!!
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: VBA Macro Button to delete entire row

    Ok

    You still do not need any buttons.

    If we consider my Macro1.

    If I right click on the sheet name at the bottom of excel and select view code.

    A module opens.

    If I paste this code in that module and close it.

    Please Login or Register  to view this content.

    So this time the macro will run if all these criteria are true
    I only select one cell
    I select a cell in column V
    Column B in that row is not empty
    The row number is 16 or more

    You could specify that the selected cell in column V must contain the text "Transfer to Archive"

    Please Login or Register  to view this content.
    This is still a lot tidier then having all those buttons.

  11. #11
    Registered User
    Join Date
    04-22-2018
    Location
    orlando
    MS-Off Ver
    2013
    Posts
    33

    Re: VBA Macro Button to delete entire row

    I'm sorry. I's so new to VBA, maybe I'm not understanding something obvious. Step 1: I created the Macro1? Step 2: View Code for the worksheet, and Paste the last code you created that states the cell has to ="transfer to Archive"? I have done those steps. But I'm not assigning the Macro to a button, just find a way to make that cell = "transfer to Archive", or what I put; "Complete". So I've done that, but when the cell in V says "Complete" nothing happens. Im really sorry, I guess I have to be baby talked into it.

  12. #12
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: VBA Macro Button to delete entire row

    There were three issues

    1. Your workbook was corrupt

    2. I had an error in my macro

    3. You need two macros. Sheet specific macros only work on the host sheet.

    So




    Please Login or Register  to view this content.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    04-22-2018
    Location
    orlando
    MS-Off Ver
    2013
    Posts
    33

    Re: VBA Macro Button to delete entire row

    Thank You. this works if you click on the blank cell in V. I tried to make it so you have to click on that cell, but it only works if that cell says "Click to Archive". It works, but I deep getting runtime errors '13 Here is what I wrote, please tell me where I went wrong

    Please Login or Register  to view this content.

  14. #14
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: VBA Macro Button to delete entire row

    This looks Ok.

    The problem is probably in the main macro.

    Have you managed to create an endless Loop?

    if all your rows look like they are ready to copy then it is possible yo set it up so the macro loops around.

    insert

    Please Login or Register  to view this content.
    at the start of your macro

    and insert

    Please Login or Register  to view this content.
    at the end of your macro
    Last edited by mehmetcik; 08-04-2018 at 10:04 PM.

  15. #15
    Registered User
    Join Date
    04-22-2018
    Location
    orlando
    MS-Off Ver
    2013
    Posts
    33

    Re: VBA Macro Button to delete entire row

    I will try that. Thank you so much for your help! I learned formulas, charts, nested formulas, formatting, now I’m on to VBA. I’ll probably come back with many more questions. Thank you

  16. #16
    Registered User
    Join Date
    04-22-2018
    Location
    orlando
    MS-Off Ver
    2013
    Posts
    33

    Re: VBA Macro Button to delete entire row

    so I tried adding those two codes, but now it doesn't work at all. It works when I remove them. Can you try explaining again why I need two macros. 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. [SOLVED] Macro Needed to Delete Entire Row if the Entire Row (Or Col A,B,C,D in row ) are blank
    By swade730 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-04-2016, 06:32 AM
  2. Macro Button to Delete Entire Row if cells in two columns are empty in certain worksheet
    By Adriana Lee in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-15-2015, 07:49 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. Replies: 4
    Last Post: 10-12-2014, 08:54 AM
  5. [SOLVED] Macro to delete entire row on a condition
    By kgonzalbo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-30-2011, 12:39 AM
  6. Macro to delete the entire row
    By Sindhuja in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-21-2008, 10:07 PM
  7. [SOLVED] Help! with Macro - delete entire row
    By Rashid in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-04-2006, 05:20 PM

Tags for this Thread

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