+ Reply to Thread
Results 1 to 15 of 15

Data Cleaning

  1. #1
    Registered User
    Join Date
    06-28-2016
    Location
    Bangkok
    MS-Off Ver
    2010
    Posts
    80

    Data Cleaning

    Hi everyone,

    Good evening. Could anyone provide me VBA code for the following requirements?

    Requirement 1: Separate data to different row if there are symbol ',':-
    • Example 1: there are BB1, BB2, BB3 for set 2. I need one row for BB1, one row for BB2 and one row for BB3 with set 2 at column A
    • Example 2: there are BB1, BB2 for set 4. I need one row for BB1 and one row for BB2 with set 4 at column A
    • Example 3: there are AA, BB1 for set 5. I need one row for AA and one row for BB1 with set 5 at column A

    Requirement 2: Remove cell (shift up) if there is no number in the cell:-
    • For example, AA for set 5 should be excluded from the list because it doesn't contain number.

    Just for your information, the real data contains more than 20,000 records and they are sticky confidential.

    Please take a look at the file attached for my expected output with samples.

    Thank you and have a nice day.
    Attached Files Attached Files
    Last edited by cmokasak; 07-28-2016 at 07:29 AM.

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,835

    Re: Data Cleaning

    Try
    Please Login or Register  to view this content.

  3. #3
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Data Cleaning

    An alternative approach:
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  4. #4
    Registered User
    Join Date
    06-28-2016
    Location
    Bangkok
    MS-Off Ver
    2010
    Posts
    80

    Re: Data Cleaning

    Hi Olly,

    it is not work.

  5. #5
    Registered User
    Join Date
    06-28-2016
    Location
    Bangkok
    MS-Off Ver
    2010
    Posts
    80

    Re: Data Cleaning

    Hi jindon,

    But, it is not work with the data similar to 'ABCD-1234-0001'.
    Please take a look at the file attached for the revised raw data.
    Attached Files Attached Files

  6. #6
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Data Cleaning

    Quote Originally Posted by cmokasak View Post
    Hi Olly,

    it is not work.
    In what way does it "Not work" ?

    It works for me. See attachment.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    06-28-2016
    Location
    Bangkok
    MS-Off Ver
    2010
    Posts
    80

    Re: Data Cleaning

    Hi Olly,

    Please see reply # 5
    In addition: when I run your code, I get the results as attached.
    Attached Files Attached Files
    Last edited by cmokasak; 07-28-2016 at 06:51 AM.

  8. #8
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Data Cleaning

    Okay, so you've changed the structure of your data. The original requirement had values seapareted by ", " in each cell. Now they are separated by just "," (see the missing space?!)

    So you need to modify the code to accommodate the different data structure.

    Change this line:
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Attention to detail is REALLY important. Values separated by ", " are not the same as values separated by ","

    It's also worth mentioning that the "Expected Output" values in your latest file upload don't actually match the "Input" values...

  9. #9
    Registered User
    Join Date
    06-28-2016
    Location
    Bangkok
    MS-Off Ver
    2010
    Posts
    80

    Re: Data Cleaning

    Thank you for your reply.

    When I run your code, I just got a blank page.

    However, when I run jindon's code, I got the results.
    But when I run with the real data, it is not work with the data similar to 'ABCD-1234-0001'.

    Please see reply # 5 for the new data samples.
    Last edited by cmokasak; 07-28-2016 at 07:08 AM.

  10. #10
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Data Cleaning

    This is getting to be hard work....

    See attachment - it's your SECOND attachment, with my code added. Click the big button. Watch it sort the data as requested.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    06-28-2016
    Location
    Bangkok
    MS-Off Ver
    2010
    Posts
    80

    Re: Data Cleaning

    That's fantastic.

    However, when you remove the number from the data to 'ABCD'.
    This is not gone according to the second requirements.

    Anyway, Thank you so much for your great work.

  12. #12
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Data Cleaning

    Quote Originally Posted by cmokasak View Post
    However, when you remove the number from the data to 'ABCD'.
    This is not gone according to the second requirements.
    Change the code to:
    Please Login or Register  to view this content.
    Better?

  13. #13
    Registered User
    Join Date
    06-28-2016
    Location
    Bangkok
    MS-Off Ver
    2010
    Posts
    80

    Re: Data Cleaning

    That's great.

    Thank you for all the responses / answers that you give me.
    It makes I feel so much appreciated.

    Have a nice day

    N.B. # 1: I have added a reputation to your profile.
    N.B. # 2: The topic has been marked resolved.

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,835

    Re: Data Cleaning

    Quote Originally Posted by cmokasak View Post
    Hi jindon,

    But, it is not work with the data similar to 'ABCD-1234-0001'.
    Change pattern to
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    11-22-2012
    Location
    Birmingham
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Data Cleaning

    That's great jindon.
    I feel so much appreciated your responses / answers that you give me.
    Have a nice day

    N.B.: I have added a reputation to your profile.

+ 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] Data Cleaning
    By cmokasak in forum Excel General
    Replies: 7
    Last Post: 07-08-2016, 03:08 AM
  2. cleaning DATA
    By OSK in forum Excel General
    Replies: 1
    Last Post: 10-30-2014, 09:51 AM
  3. Help cleaning up data
    By Impartial Derivative in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-12-2011, 01:26 PM
  4. Cleaning data
    By cool.chatbot in forum Excel General
    Replies: 11
    Last Post: 02-09-2011, 03:31 AM
  5. Need Help With Cleaning Data
    By fennman in forum Excel General
    Replies: 6
    Last Post: 07-10-2008, 06:42 AM
  6. Data cleaning
    By a303 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-20-2007, 03:10 PM
  7. Data Cleaning
    By mazmjh in forum Excel General
    Replies: 1
    Last Post: 11-27-2006, 12:12 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