+ Reply to Thread
Results 1 to 11 of 11

Need a macro that will delete/add row

  1. #1
    Registered User
    Join Date
    11-24-2012
    Location
    United States
    MS-Off Ver
    Mac Excel 2011
    Posts
    64

    Need a macro that will delete/add row

    I have a document that I want to be able to delete out of any row, start a macro that will delete that row out of another sheet where I am referencing that data. Once that operation is done I want the row to move up and my formulas in the next row will stay intact.

    Copy of US05 - MPTS_test version.xlsm

  2. #2
    Registered User
    Join Date
    11-24-2012
    Location
    United States
    MS-Off Ver
    Mac Excel 2011
    Posts
    64

    Re: Need a macro that will delete/add row

    Main data is in new inventory, which is being referenced in scrap log.

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

    Re: Need a macro that will delete/add row

    Your explanation is not clear. Please provide examples using your spreadsheet for clarification. What is the logic?
    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

  4. #4
    Registered User
    Join Date
    11-24-2012
    Location
    United States
    MS-Off Ver
    Mac Excel 2011
    Posts
    64

    Re: Need a macro that will delete/add row

    1.) Delete row 2 in New inventory. This will create a "#REF!" error in row 2 of Scrap Acitvity Log.
    2.) Run a Macro that will delete row 2 in the Scrap activity Log.
    3.) Then Move all rows up to keep formulas intact. - The same logic as when you delete a line and the next row automatically moves up.

  5. #5
    Registered User
    Join Date
    11-24-2012
    Location
    United States
    MS-Off Ver
    Mac Excel 2011
    Posts
    64

    Re: Need a macro that will delete/add row

    I should be able to delete any row in New Inventory and run this macro and it will find the "#Ref!" and delete the entire row.

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

    Re: Need a macro that will delete/add row

    Try this:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-24-2012
    Location
    United States
    MS-Off Ver
    Mac Excel 2011
    Posts
    64

    Re: Need a macro that will delete/add row

    Ok, that works thanks. Now say that if I wanted to add a new row of data on the new inventory worksheet and wanted my formula to continue when I add a New row of data. Could I incorporate that into this delete function.

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

    Re: Need a macro that will delete/add row

    Would the new row be added to the end of the newInventory sheet? With every deletion, would there be an addition?

    You would probably be better off with a separate macro unless for every row deleted, there is one added.

    Please explain in as much detail as necessary what you are wanting to do. General questions, generally get inconclusive resposnses.

  9. #9
    Registered User
    Join Date
    11-24-2012
    Location
    United States
    MS-Off Ver
    Mac Excel 2011
    Posts
    64

    Re: Need a macro that will delete/add row

    Can I start the Macro when I open the document and when I delete the row it deletes the rows in scrap activity. Because I would have to run the macro every time I delete a row rather and it being automated and just does it upon deletion of a row. Yes that is fine as long as the next row following the one that was deleted will move up and the the formula stay the same.

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

    Re: Need a macro that will delete/add row

    I am now confused by what you wish to do. Please give me a step by step of what it is you are trying to do and make sure to reference each sheet as you explain. Explain what you are doing manually, and then what you would like to happen automatically. Please be precise.

  11. #11
    Registered User
    Join Date
    11-24-2012
    Location
    United States
    MS-Off Ver
    Mac Excel 2011
    Posts
    64

    Re: Need a macro that will delete/add row

    Step 1. Load macro on opening of document and run in the background.
    Step 2. Delete a row from the worksheet "New Inventory"
    Step 3. "#REF" - is created in "Scrap Activity log" when the row is deleted from "New Inventory"
    Step 4. Macro will auto-delete the line once it scans for error in rows.
    Step 5. All data in "Scrap Activity will then shift up to the next row.
    Step 6. A new row will be created after the last row and the formula will be continued in this new row.

+ 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. Run Macro Automatically When delete row , changes cell,delete column
    By elevisse in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-27-2012, 07:42 AM
  2. Macro to delete certain columns and delete rows based on time in another column
    By beepbeep27 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2012, 11:47 AM
  3. [SOLVED] Macro to delete sheets and saves remaining file does not properly delete module
    By pherrero in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-21-2005, 08:12 PM
  4. Replies: 0
    Last Post: 06-21-2005, 01:05 PM
  5. [SOLVED] Re: Macro to delete sheets and saves remaining file does not properly delete module
    By pherrero in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-21-2005, 01:05 PM

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