+ Reply to Thread
Results 1 to 6 of 6

Macro to delete rows with certain details in, but to keep other rows

  1. #1
    Registered User
    Join Date
    02-11-2013
    Location
    Copenhagen
    MS-Off Ver
    Excel 2007
    Posts
    58

    Macro to delete rows with certain details in, but to keep other rows

    Hi

    I copy and paste data in to Excel from another software, not Excel, and then through Marcos and If statements, I format the data and check that it is correct, however, when I paste, rows that are hidden become unhidden and then messes up my If statements (as the hidden cells don’t apply to the rules in my If statements).

    I have attached an example of the data I am pasting in.
    Delrow.jpg
    Row 2,3,4,6,7,9,10,12,13,14,16,17,19,20 are hidden in the software I use, as these are netted items that are netted together for some parties e.g. Party A and this will make a Total row (which is the row I need to use).

    The rows I would need would be 1,5,8,11,15,18,21,22,23,24 and 25 but this is not the same each time as the data varies.

    What I can see and hope to be able to use to make a macro is that in column H have numbers in for the netted (hidden rows) and hope to write something like:

    If Column G has a number and H doesn’t have “Total” in it delete the row. If Column G is blank or Colum H has “total” in it, then keep the row. I think this would solve my problem.

    I would need this is a Marco though as I would need to paste the information in then format the data using this, but it would have to run down until the last row of data.
    I have tried a few ways of get this, but my skills aren’t good enough yet.
    I hope someone can help me.

    Thanks

    Rob
    Attached Files Attached Files
    Last edited by Robert110; 03-07-2013 at 02:34 PM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Macro to delete rows with certain details in, but to keep other rows

    A jpg file will not help. Please attach an excel sample file -

    To Attach a File:

    1. Click on Go Advanced
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    02-11-2013
    Location
    Copenhagen
    MS-Off Ver
    Excel 2007
    Posts
    58

    Re: Macro to delete rows with certain details in, but to keep other rows

    HI,

    Thanks for the info,

    I have attahced it now,

    I haven't included the "IF" statement in this version, as they are a bit messy at the moment.

    But let me know if you need this included and I will add them
    Thanks
    Rob

  4. #4
    Registered User
    Join Date
    02-11-2013
    Location
    Copenhagen
    MS-Off Ver
    Excel 2007
    Posts
    58

    Re: Macro to delete rows with certain details in, but to keep other rows

    Hi

    Did the spreadsheet help at all or does it need me to explain futher?

    Please let me know if this is unclear.

    Rob

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Macro to delete rows with certain details in, but to keep other rows

    Try this code

    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose View | Macros
    Select a macro in the list, and click the Run button

  6. #6
    Registered User
    Join Date
    02-11-2013
    Location
    Copenhagen
    MS-Off Ver
    Excel 2007
    Posts
    58

    Re: Macro to delete rows with certain details in, but to keep other rows

    Wow!

    That is amazing. thank you very much arlu1201
    This has helped me out so much.

    It works perfectly

    Thanks again

    Robert110

+ 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