+ Reply to Thread
Results 1 to 4 of 4

Macro or VBA to Clean Up Messy Data

  1. #1
    Registered User
    Join Date
    06-07-2021
    Location
    New York, USA
    MS-Off Ver
    2016
    Posts
    2

    Question Macro or VBA to Clean Up Messy Data

    I received data that has come across a little out of order. Each row should include the following fields without any blanks:

    Original Row, Index Number, Case, Date1, Action1 (Most cases will have more Date and Action columns).

    I am trying to build a macro that will move the date and action cells to the correct positions. See below for example

    Example1.jpg

    Example 2.jpg

    I have thousands of records of data that I need to do this for before I can begin my testing. The max number of Dates and Actions that one Index number has is 17 (Date17, Action17).

    My thought process on what to do is below, however it is still flawed.

    Begin in the first Index Number cell. Determine if there is text in the cell. If yes, move down one row and perform the same test. If there is no text, move to the right until a cell with text is selected, or until Column E (then return to Index Number Column and move down one row). Cut the selected cell if text was found. Move Up one cell. If there is data in this cell, move right one. If there is NO data in this cell, paste. If there is data, continue shifting to the right one cell until an empty space is identified. Return to the cell that had the text cut. Move to the right one cell until Column E and repeat the process.

    I do not want to write over any of the data in the Index Number and Case Column, I only want to move the Date and Action Items beneath it up into the correct row.

    I've attached a sample workbook to this thread.

    Thanks!
    Mike
    Attached Files Attached Files

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Macro or VBA to Clean Up Messy Data

    Try:
    Please Login or Register  to view this content.
    Change the sheet name (in red) to suit your needs.
    Last edited by Mumps1; 06-07-2021 at 09:59 AM.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    06-07-2021
    Location
    New York, USA
    MS-Off Ver
    2016
    Posts
    2

    Re: Macro or VBA to Clean Up Messy Data

    We are all set actually! I didn't even realize it worked 100% and had just come to its logical end!! Thank you! +1 Rep

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Macro or VBA to Clean Up Messy Data

    You are very welcome and thanks for the rep.

+ 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] Clean Up Messy Code - Works, but has Issues
    By Rick-O-Shay in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-09-2020, 11:57 PM
  2. [SOLVED] Messy recorded VBA which runs slow. I need help in trying to clean the coding up.
    By shina67 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-24-2019, 03:50 AM
  3. Replies: 10
    Last Post: 08-09-2017, 02:17 AM
  4. Stop values from being entered and clean up messy code
    By cgibbons461 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-31-2017, 11:02 AM
  5. Replies: 2
    Last Post: 05-23-2015, 08:27 AM
  6. [SOLVED] VBA Code to optimize and clean data- clean out numerical/ or symbol
    By tracylsr in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-05-2012, 04:21 PM
  7. [SOLVED] Transforming messy database into clean database
    By SteveC in forum Excel General
    Replies: 4
    Last Post: 01-24-2006, 07:35 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