+ Reply to Thread
Results 1 to 3 of 3

Remove Blank Cells in a Selection

  1. #1
    Registered User
    Join Date
    03-10-2005
    Posts
    6

    Remove Blank Cells in a Selection

    I have a range selected in a Column and am trying to delete the Blank cells out. The following code works if there are blank cells in the range, but if there are not it gives an error.

    Selection.SpecialCells(xlCellTypeBlanks).Delete Shift:=xlUp




    Is there a way of doing it so it doesn't give an error, or should I just do On Error Resume Next for this section of the macro?

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284
    Quote Originally Posted by Krager
    I have a range selected in a Column and am trying to delete the Blank cells out. The following code works if there are blank cells in the range, but if there are not it gives an error.

    Selection.SpecialCells(xlCellTypeBlanks).Delete Shift:=xlUp

    Is there a way of doing it so it doesn't give an error, or should I just do On Error Resume Next for this section of the macro?
    On Error Resume Next
    Selection.SpecialCells(xlCellTypeBlanks).Delete Shift:=xlUp
    On Error GoTo 0

  3. #3
    Registered User
    Join Date
    03-10-2005
    Posts
    6
    Thanks, works perfectly

+ 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