+ Reply to Thread
Results 1 to 10 of 10

Deleting worksheet rows based on if the first column cell is empty

  1. #1
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    594

    Deleting worksheet rows based on if the first column cell is empty

    Good Afternoon!

    I copied over two columns of data from a larger spreadsheet and pasted them to a temporary worksheet starting at ("B3") on the temporary.

    As the second column ("C") is always populated with some value I use it to determine the last row of a range that varies from one run to another.

    Before processing any further I need to eliminate any row on the temporary sheet in which the cell in the first column ("B") is empty.

    wsCH has been Set to the temporary worksheet.

    Is there a more efficient way to accomplish this than the following?

    Please Login or Register  to view this content.
    I am asking for even with just 100 original rows of data this part of the routine consumes the greatest amount of time-

    Thank-you for your thoughts!

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,016

    Re: Deleting worksheet rows based on if the first column cell is empty

    .
    This deletes 1,000 blank rows in under 1 second.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    594

    Re: Deleting worksheet rows based on if the first column cell is empty

    Thank-you; interesting approach. Going to give it a timed try!

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,016

    Re: Deleting worksheet rows based on if the first column cell is empty

    .
    How long does it take with your code ? How many blank rows ?

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,913

    Re: Deleting worksheet rows based on if the first column cell is empty

    Without a loop.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  6. #6
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    594

    Re: Deleting worksheet rows based on if the first column cell is empty

    If I wasn't so tied up in a thousand irritating questions at work I would try that out right now! Looking forward to and reporting back, many thanks!

    edit: I took care of a few issues then broke off to try bakerman2's suggestion. While I was quite happy with Logit's solution, what bakerman2 wrote blew me away in speed. Don't know why my computer was lagging so much with either my or Logit's approach, but avoiding the vba loop helped tremendously.
    Last edited by brucemc777; 08-04-2017 at 04:15 PM.

  7. #7
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,016

    Re: Deleting worksheet rows based on if the first column cell is empty

    .
    bakerman's code is elegant and clean.

  8. #8
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    594

    Re: Deleting worksheet rows based on if the first column cell is empty

    I am now wondering how many other times I have wasted time on loops when something like that could have been used...

  9. #9
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,913

    Re: Deleting worksheet rows based on if the first column cell is empty

    Thanks for feedback and for rep+.

  10. #10
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    594

    Re: Deleting worksheet rows based on if the first column cell is empty

    Great thanks for the help!!!

+ 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] Macro code for deleting empty rows in the output worksheet
    By macrolearnerkk in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-07-2015, 02:06 PM
  2. How to delete rows based on whether or not a cell in column B is empty or null
    By Seth_ in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-25-2014, 04:35 PM
  3. Delete Rows Based On Empty Cell in Column Works Perfectly For A, but Not J
    By votekinky06 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-27-2014, 05:41 PM
  4. Deleting empty rows from ACTIVE column
    By noobtron in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-01-2012, 06:26 PM
  5. Deleting rows with empty cells in a specific column
    By vzw1965 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-09-2011, 10:55 AM
  6. Deleting empty rows if specific cell in row is empty
    By csynic in forum Excel General
    Replies: 0
    Last Post: 07-06-2011, 01:43 AM
  7. [SOLVED] Deleting empty rows in a worksheet
    By danw in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-27-2006, 04:50 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