+ Reply to Thread
Results 1 to 4 of 4

Newbie want to take out empty cells with macro

  1. #1
    Registered User
    Join Date
    10-06-2015
    Location
    Luzern
    MS-Off Ver
    MS Office 2007
    Posts
    2

    Red face Newbie want to take out empty cells with macro

    Hello World,
    I`m 17 years old and got the pleasure to play with macros in my company.
    I`m a newbie..:D

    Soo, my Problem:
    I have a .csv with about 2000 records witch describes persons.
    Between the name and the data of these persons is one column for the title and 0-9 empty Cells.
    Some persons have no title, so the Cells of the second column are sometimes empty.
    A Person can have 0-200 of these "data-cells".

    [Robert][Executor][Empty Cell][Empty Cell][Empty Cell][Empty Cell][Data1][Data2][Data3][Data4][Data5][Data6][Data7]
    [Henry][Chief][Data1][Data2][Data3][Data4]...
    [Angie][Empty Cell][Empty Cell][Empty Cell][Empty Cell][Data1]
    [Roland][Empty Cell][Empty Cell][Empty Cell][Empty Cell][Empty Cell][Empty Cell]...
    [Sue][Worker][Empty Cell][Empty Cell][Data1][Data2][Data3][Data4]...

    I want to take out the empty cells, except the column "Title".
    In the end, it should look like this:

    [Robert][Executor][Data1][Data2][Data3][Data4][Data5][Data6][Data7]
    [Henry][Chief][Data1][Data2][Data3][Data4]...
    [Angie][Empty Cell][Data1]
    [Roland][Empty Cell]
    [Sue][Worker][Data1][Data2][Data3][Data4]...

    In my opinion, i should build a for loop that removes the data from the next cell and put it into the actual cell, but only if the actual cell was empty..
    The problem would be the column "Title", witch cells have to remain empty, if they were empty.
    I could solve the problem with extracting the column "Title" to another excel, delete the data from column B, export csv, import csv comma delimited, search_replace the ",," with "," ten times and insert the column "Title" but this solution isn`t elegant, not efficient and not comfortable for my co-workers.

    Anybody knows a solution?

    PS. Sorry for my bad English, hope you could understand..
    Last edited by barmiextreme; 10-06-2015 at 07:55 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,445

    Re: Newbie want to take out empty cells with macro

    Untested (no computer today) but maybe something like:


    Please Login or Register  to view this content.
    Adjust columns (C and HZ) and rows (2000) to meet your requirements and check syntax.

    Test on a copy of the workbook/worksheet.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    10-06-2015
    Location
    Luzern
    MS-Off Ver
    MS Office 2007
    Posts
    2

    Re: Newbie want to take out empty cells with macro

    Thanks so much, TMS!

    This is exactly what i`ve looked for.
    Never thought that i could solve this with one simple line!

    Have a nice day, Barmi from Switzerland

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,445

    Re: Newbie want to take out empty cells with macro

    You're welcome. Thanks for the rep.

    To be fair, not so long ago, I would probably have coded a double look processing some 40,000 cells one by one. . We all live and learn


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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. Macro to copy paste specific cells into empty cells below them
    By qlo_0lp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-23-2014, 04:49 PM
  2. [SOLVED] If certain cells are not empty then alert macro
    By ScabbyDog in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-11-2014, 11:36 AM
  3. [SOLVED] Copying into empty cells 2 - macro
    By butlerar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-29-2014, 03:57 PM
  4. [SOLVED] How to run macro till empty cells
    By majdi.marmas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-29-2013, 12:58 PM
  5. MACRO to empty a range of cells based on whether specified cell is empty
    By TBJV in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-01-2013, 10:35 PM
  6. Copy Non-Empty Cells Macro
    By kvanb796 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-28-2008, 05:44 PM
  7. macro to colour empty cells (cells not recognized as empty)
    By Gerben in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-30-2005, 11:05 AM

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