Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Remove Unprintable Non-Blank Cells Having Zero Length Contents

  1. #11
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    Rep Power
    10
    I understand this may be a memory intensive code loop, but it worked for me with your sample file

    Code:
    Sub ClearNonLenCells()
    
        Dim C As Range
        For Each C In ActiveSheet.UsedRange.SpecialCells(xlCellTypeConstants)
            If Len(C) = 0 Then
                C.ClearContents
            End If
        Next C
        
    End Sub
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  2. #12
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    659
    Rep Power
    13
    Quote Originally Posted by Excel Fox View Post
    I understand this may be a memory intensive code loop, but it worked for me with your sample file
    Where did you see the sample file at? I do not see attachments for this thread... do I have a setting wrong or did you use the file the OP posted yesterday in Message #3?

  3. #13
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    Rep Power
    10
    #3 Rick
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  4. #14
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    659
    Rep Power
    13
    Quote Originally Posted by Excel Fox View Post
    I understand this may be a memory intensive code loop, but it worked for me with your sample file

    Code:
    Sub ClearNonLenCells()
    
        Dim C As Range
        For Each C In ActiveSheet.UsedRange.SpecialCells(xlCellTypeConstants)
            If Len(C) = 0 Then
                C.ClearContents
            End If
        Next C
        
    End Sub
    It looks like the empty cell is coming in as the text value "" instead of actually being empty. You can see this by adding the one formula the OP did not try...

    =ISTEXT(A1)

    I think this will fix the file also (should be less memory intensive than your macro)...

    Code:
    Sub FixFile()
      Dim Ar As Range
      On Error GoTo NoText
      For Each Ar In Cells.SpecialCells(xlConstants, xlTextValues)
        Ar.Value = Ar.Value
      Next
    NoText:
    End Sub

  5. #15
    Junior Member
    Join Date
    May 2013
    Posts
    20
    Rep Power
    0
    Just tried your macro Rick. Worked a treat. Thanks

Similar Threads

  1. How can I make MLOOKUP to ignore blank cells?
    By radionut in forum Excel Help
    Replies: 1
    Last Post: 07-22-2013, 09:18 AM
  2. Replies: 5
    Last Post: 07-11-2013, 07:31 AM
  3. Replies: 13
    Last Post: 06-10-2013, 09:05 AM
  4. Replies: 2
    Last Post: 09-24-2012, 11:19 PM
  5. Highlighting Blank Cells
    By Howardc in forum Excel Help
    Replies: 2
    Last Post: 08-13-2012, 07:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •