+ Reply to Thread
Results 1 to 8 of 8

Macro to remove lines in Data set if Column A value is blank

  1. #1
    Registered User
    Join Date
    09-17-2014
    Location
    Cambridge, England
    MS-Off Ver
    2016
    Posts
    58

    Macro to remove lines in Data set if Column A value is blank

    Hello All,

    I have a large set of data that is extracted out of a very old piece of software in Excel format. The layout is pretty rubbish and it is riddled with blank values.

    What I want to achieve is a very quick Macro to simply run down the list of data and remove the whole line if the value in Column A is blank.

    I have attached a before and after version of Excel to see what I want to achieve. The normal extract will normally contain between 1500 - 2500 lines of data, hence why a Macro would really make my life easier.

    Thanks for your help.

    Regards
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Macro to remove lines in Data set if Column A value is blank

    Try this:

    Please Login or Register  to view this content.

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,236

    Re: Macro to remove lines in Data set if Column A value is blank

    Hi sx200n

    Try this:
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  4. #4
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Macro to remove lines in Data set if Column A value is blank

    Hi Sintek,

    Not sure if you looked at the sample file however a couple of reason why your code won't do what is needed in this instance.

    The "Blank" cells in column A actually contain spaces (either 10 or 1) so they are not technically blank cells.

    The lastrow in Column A is not the last row of data which may need to be deleted, rather this is in Column D.

  5. #5
    Registered User
    Join Date
    09-17-2014
    Location
    Cambridge, England
    MS-Off Ver
    2016
    Posts
    58

    Re: Macro to remove lines in Data set if Column A value is blank

    Sintek & PFDave - both work a treat.

    Thanks for your help.

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,236

    Re: Macro to remove lines in Data set if Column A value is blank

    @ PFDave

    Nice catch...Did not even notice that....Thanks

  7. #7
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Macro to remove lines in Data set if Column A value is blank

    Quote Originally Posted by sintek View Post
    @ PFDave

    Nice catch...Did not even notice that....Thanks
    That's ok, seems from the above comment that it worked anyway :/

    I only mentioned it to explain why it may not work in this example, but there's some bits in their I didn't know about that I'll use

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,236

    Re: Macro to remove lines in Data set if Column A value is blank

    I guess OP's actual workbook just had blanks....
    Amended with lRow in D
    Please Login or Register  to view this content.

+ 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] Remove blank lines
    By ReeceB in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-01-2015, 06:23 PM
  2. [SOLVED] remove blank lines in text document before pputting data in excel
    By Jenkins27 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-02-2015, 05:19 PM
  3. [SOLVED] Macro neede to open text files from folder and remove all the lines except specific lines
    By genetist in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 10-07-2014, 02:44 AM
  4. [SOLVED] inserting two blank lines when based on data in a column
    By El Conquistador in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-08-2013, 02:05 PM
  5. How do I remove blank lines in the first column.
    By SWMagic in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-29-2013, 05:14 AM
  6. Remove Blank Lines
    By Robotacha2010 in forum Excel General
    Replies: 5
    Last Post: 08-16-2010, 11:59 AM
  7. [SOLVED] Remove Blank Lines
    By Nigel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-28-2005, 11:00 AM

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