+ Reply to Thread
Results 1 to 6 of 6

Macro can see the formulas and thus cells are not empty

  1. #1
    Registered User
    Join Date
    06-22-2012
    Location
    Glasgow
    MS-Off Ver
    Excel 2007
    Posts
    3

    Macro can see the formulas and thus cells are not empty

    Hi guys,

    Here's the macro:

    =========================================================
    Sub Macro1()

    Dim i As Long

    'Range("A9:J2000").Select

    For i = Selection.Rows.Count To 1 Step -1
    If WorksheetFunction.CountA(Selection.Rows(i)) = 0 Then
    Selection.Rows(i).EntireRow.Delete
    End If
    Next i

    End Sub
    =========================================================

    ..unfortunately cells with no values but only with formulas in them are being treated as non-content-free and are not being removed.

    Generally what I'm looking for is a quickest macro to remove all rows that are empty (not even single cell in the row has any value), any help very appreciated.

  2. #2
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Macro can see the formulas and thus cells are not empty

    Try this:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-22-2012
    Location
    Glasgow
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Macro can see the formulas and thus cells are not empty

    Thanks for reply, unfortunately it deletes wrong rows and also rows outside the defined range (4 rows above row 9).

  4. #4
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Macro can see the formulas and thus cells are not empty

    Sorry, thought you wanted to delete the rows with values.
    Changed it to the ones with no values.
    Above 9 is solved by setting the loop to 9, change if you need to.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-22-2012
    Location
    Glasgow
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Macro can see the formulas and thus cells are not empty

    Yeah that works fine - thanks a lot.

    But.. your method takes same amount of time to sort out given range as method I am using currently. They are both quite slow.

    My goal is to find much faster method.

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Macro can see the formulas and thus cells are not empty

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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