Results 1 to 4 of 4

Deleting Entire Row Based on Criteria in single cell

Threaded View

  1. #1
    Registered User
    Join Date
    04-07-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    22

    Deleting Entire Row Based on Criteria in single cell

    Preface: I am learning VBA as I go over the last three weeks, so please explain any solutions like i'm a complete idot. Thank you so much in advance for any help.


    Prefered:

    I want to Delete an entire row based on a criteria in column D (Criteria:= "REMOVAL BLANKET")

    Or

    Acceptable:

    I would Like to Delete all Visible Rows from a Flitered Selection of Colum D.

    My Current code is
    :
    See ISSUE 1: I need to get the entire row selected to delete. cant seem to scipt it right

    Sub REMOVAL_BLANKET()
    '
    ' REMOVAL_MACRO
    '
    ' Keyboard Shortcut: Ctrl=g
    '
    Dim y As String
    Dim X As Integer
    Dim ba As String
    Dim ba1 As Variant
    
    Range("D2").Select
    
    ' Dimension variables.
       y = ActiveCell    ' Change this to True if you want to
       X = 1        ' delete rows 1, 3, 5, and so on.
       I = 1
       xRng = X
    
       ' Loop once for every row in the selection.
       
       ba = ActiveCell
       ba1 = ba
       
       For xCounter = I To 114
       
       'ActiveCell.Offset(rowoffset:=1).Select
       
        
    y = ActiveCell
           ' If Y is True, then...
                  If y <> "REMOVAL BLANKET" Then
    I = I + 1
               ' ...delete an entire row of cells.
               GoTo first
           ' Otherwise...
           Else
        ActiveCell.Offset(columnoffset:=-3).Select
        
        
           Selection.End(xlToRight).Select
        Range(ActiveCell, ActiveCell).Delete Shift:=xlToLeft  <--- ISSUE 1
               ' ...increment I by one so we can cycle through range.
               If ActiveCell = "Z" Then
               y = ActiveCell
               GoTo first
               Else
                          
                         
               If y = "Z" Then
               Selection.End(xlToRight).Select
               'Range(ActiveCell, ActiveCell.Offset(columnoffset:=-255)).Select
               ActiveCell.Offset(Rowoffset:=1).Select
               GoTo Third
    
           End If
           End If
           End If
    
           ' If Y is True, make it False; if Y is False, make it True.
    first:
    
    
    Third:
       ActiveCell.Offset(Rowoffset:=1).Select
       Next
    
    
    
    
    End Sub
    Last edited by Leith Ross; 04-07-2011 at 03:46 PM. Reason: Added Code Tags

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