Results 1 to 16 of 16

Delete Rows If condition not met

Threaded View

  1. #1
    Forum Contributor
    Join Date
    05-13-2009
    Location
    London, England
    MS-Off Ver
    Excel XP
    Posts
    174

    Delete Rows If condition not met

    Hi I want a macro to delete the entire row based on the value in Column Q

    I've trid to write a code but it doesnt work

    Sub marg()
    
    
    Dim cell As Range
    Dim Ranger As Range
    Dim t As Long
    
    t = Sheets("marg").Range("Q" & Rows.Count).End(xlUp).Row
    Set Ranger = Sheets("marg").Range("Q2:Q" & t)
    
    For Each cell In Ranger
            If cell.Value <> "EUR" Or "FUTURE" Or "SHORT" Or "SPAN" Or "TIME" Then
              
                cell.EntireRow.Delete
           
            
            End If
            
        Next cell
    
    End Sub
    So basially only if the cell in Column Q has value of EUR or FUTURE or SHORT or SPAN or TIME then the row maintains status quo, otherwise entire row has to be deleted

    any thoughts?

    thanks
    Last edited by Pasha81; 12-17-2009 at 02:12 PM.

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