+ Reply to Thread
Results 1 to 12 of 12

Macro to Delete useless lines, rearrange by dates and skip lines between different days.

  1. #1
    Registered User
    Join Date
    06-11-2012
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    62

    Macro to Delete useless lines, rearrange by dates and skip lines between different days.

    Sort Columns Appropriately
    Attached Files Attached Files
    Last edited by Tmc2159; 06-12-2012 at 06:13 PM.

  2. #2
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Macro to Delete useless lines, rearrange by dates and skip lines between different day

    Tmc2159,

    Welcome to the Excel Forum.


    Step 1:
    I want to delete any row which has the words "Not Given." in Column J.

    Step 2:
    I want to sort all the Rows by the date given in Column C.

    Step 3:
    I want to arrange the Number together.
    Meaning all the Mach 1 should be together and Mach 2 should be together if they have the same date.

    Step 4:
    I want to skip a line when the date changes.

    Step 5 ( Optional):
    I would like my different dates to be seperated in different sheets but that probably can not be done in excel.

    All of the above is doable.


    When we create the new worksheets for the dates in column C, Excel will not allow us to use this format "5/2/2012" (we can not use the / character in a sheet name.

    We could use 5-2-2012. Is this acceptable?


    Can you supply another Template.xlsx file, containing the same Data worksheet, and containing (manually formatted by you) what the worksheet for the date "5-2-2012" will look like (titles, data from worksheet Data, etc.)?

    And, can we have another worksheet Temp, that will show us what worksheet Data will look like after the macro?
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  3. #3
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: Macro to Delete useless lines, rearrange by dates and skip lines between different day

    Try the code below, which should take you up to the optional item. It is doable but it's a bit late/early here for me to mess with it today.
    P.S. turn your filter off before running the code.

    Please Login or Register  to view this content.
    If my solution worked (or not) please let me know. If your question is answered then please remember to mark it solved

    Computers are like air conditioners. They work fine until you start opening windows. ~Author Unknown

  4. #4
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Macro to Delete useless lines, rearrange by dates and skip lines between different day

    Tmc2159,


    Detach/open workbook Template_Tmc2159_EF837368_SDG15.xlsm and run the UpdateCreateSheets macro.


    If you want to use the macro on another workbook:


    Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

    1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
    2. Open your workbook
    3. Press the keys ALT + F11 to open the Visual Basic Editor
    4. Press the keys ALT + I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
    7. Press the keys ALT + Q to exit the Editor, and return to Excel
    8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


    Please Login or Register  to view this content.

    Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm


    Then run the UpdateCreateSheets macro.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    06-11-2012
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Macro to Delete useless lines, rearrange by dates and skip lines between different day

    Thank you so much for all the help !!!

    I never expected people to be so willing to help. This already saves me hours of work which for a small business is just so valuable.

    If possible I would like to ask one more question.

    I was unclear about what I am doing and decided it would be easier to just attach a template of work I have done by hand. I made it smaller so that it was easier to understand what i am doing. (deleted some entires normally these have about 1500 entries).

    I want to go from the first sheet to the second using a macro automatically as I currently do this by hand.

    However i want the lines for which the equipment is not running to be automatically not to appear on the second sheet.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Macro to Delete useless lines, rearrange by dates and skip lines between different day

    Tmc2159,

    OK, now we have six steps to the macro.

    Step 1: I want to delete any row which has the words "Not Given." in Column J.
    Step 2: I want to sort all the Rows by the date given in Column C.
    Step 3: I want to arrange the Number together. Meaning all the Mach 1 should be together and Mach 2 should be together if they have the same date.
    Step 4: I want to skip a line when the date changes.
    Step 5: I would like my different dates to be seperated in different sheets but that probably can not be done in excel.
    Step 6: However i want the lines for which the equipment is not running to be automatically not to appear on the second sheet.


    Are the above six steps correct?

  7. #7
    Registered User
    Join Date
    06-11-2012
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Macro to Delete useless lines, rearrange by dates and skip lines between different day

    Changed Question My fault End of this Thread
    Attached Files Attached Files
    Last edited by Tmc2159; 06-12-2012 at 06:14 PM.

  8. #8
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Macro to Delete useless lines, rearrange by dates and skip lines between different day

    Tmc2159,

    So, you want to go just from sheet Data to Sheet1?

    What ever happened to a separate sheet for each date?

    Your latest template shows Sheet1 with "Equipment Not Running." rows.

    And, the data is not sorted by date, and then by the "Mach's"?

    We need another template that shows Sheet1 correctly.
    Last edited by stanleydgromjr; 06-12-2012 at 12:13 PM.

  9. #9
    Registered User
    Join Date
    06-11-2012
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Macro to Delete useless lines, rearrange by dates and skip lines between different day

    Sorry for the confusion,

    We are trying to go from Sheet1 to Data, not the other way around.

    The seperate sheet was great and worked perfectly so I don't need anything else with it.

    Sheet1 is the beginning, Data should be the Product.

    I think this is where the confusion came from: " Sheet1 is the beginning, Data should be the Product. "

    Not Given. and Equipment not running. are two ways to say the same thing.

    Newer documents like the ones I want to use the macro on, will say Equipment Not running. Sorry for the confusion, I had not noticed the change myself !

    Thanks again.

  10. #10
    Registered User
    Join Date
    06-11-2012
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Macro to Delete useless lines, rearrange by dates and skip lines between different day

    I am not sure whether my reply went through. It doesn't appear on my screen so I will answer #8 again.

    We want to go from Sheet1 to Data (Sorry for the confusion).

    Seperate Sheet for each data worked great, so I don't need any more work with that one.

    Equipment Not running. = Not Given., I hadn't noticed they updated that but I managed to change it so that it deletes Equipment Not Running. rows !

    You will find that in "data", the data is sorted by date and Mach's.

    I think the confusion came from the fact that you go from Sheet1 to Data and not the other way around.

  11. #11
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Macro to Delete useless lines, rearrange by dates and skip lines between different day

    Tmc2159,

    I am totally confused from all the changes you have gone thru.

    In the Quick Reply box, just put the word BUMP. Then, click on the Post Reply button, and someone else will assist you.

  12. #12
    Registered User
    Join Date
    06-11-2012
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Macro to Delete useless lines, rearrange by dates and skip lines between different day

    Issue was Solved
    Attached Files Attached Files
    Last edited by Tmc2159; 06-12-2012 at 06:14 PM.

+ 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