+ Reply to Thread
Results 1 to 6 of 6

VBA Code for deleting rows where cell in column a states "delete row"

  1. #1
    Registered User
    Join Date
    01-23-2009
    Location
    Oregon
    MS-Off Ver
    Excel 2003
    Posts
    35

    VBA Code for deleting rows where cell in column a states "delete row"

    I'm trying to get a VBA macro put together that would delete all the rows, throughout every sheet, and shift up wherever the cell in column A = "Delete Row" in a workbook I've made. In the below copy of the workbook you can see that a lot of the information from all the tables is linked to the topmost table on the 'Mix Detail Sheet'.

    If the the Cell in column A is blank on that first table, its corresponding cells in tables throughout the workbook displays the words "Delete Row". I need the macro to delete the rows and shift everything up where this occurs.

    Ideally I'd also like the macro to then delete the rows in that first table where the column A cells are blank.

    Let me know if I need to be more clear of if there are any questions. And thank you to anyone who can find the time to help me out. I've tried to adapt many of the other 'Delete Row' macros on this site to my situation, but I have not had very much success and I thought it was time to ask.
    Attached Files Attached Files
    Last edited by tnfire; 03-20-2009 at 06:17 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: VBA Code for deleting rows where cell in column a states "delete row"

    Try this:
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    01-23-2009
    Location
    Oregon
    MS-Off Ver
    Excel 2003
    Posts
    35

    Re: VBA Code for deleting rows where cell in column a states "delete row"

    The code works perfectly for deleting the rows where column A says "Delete Row". Which is the majority of what I was looking to do. So thank you for that, it is very helpful. The only thing that I can think of that would improve it is a statement that tells the module to Delete that first table - A4:A39 - where A is blank?

    This is the code I added below the first with statement, a simple modification of what is between the quotations in the code you supplied.

    Please Login or Register  to view this content.
    It works but as I expected it deletes my spacing between tables as well.

    I need it to delete the rows from just the first table, A4:A39, where A is blank.

    Thank you again, very much, for your previous help.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: VBA Code for deleting rows where cell in column a states "delete row"

    If you create a named range that refers to the table area, you can change your added code from wks.UsedRange to Worksheets("Mix Detail Sheet").Range("myTable").

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA Code for deleting rows where cell in column a states "delete row"

    A separate macro, or insert the important bits into the other macro.
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  6. #6
    Registered User
    Join Date
    01-23-2009
    Location
    Oregon
    MS-Off Ver
    Excel 2003
    Posts
    35

    Re: VBA Code for deleting rows where cell in column a states "delete row"

    It worked perfectly JB. Thank you both for you help. I hope that someday when I'm able I'll be able to pay it forward.

+ Reply to Thread

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