+ Reply to Thread
Results 1 to 2 of 2

Delete rows or Clear contents below a specific word is found in Column A

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Post Delete rows or Clear contents below a specific word is found in Column A

    Hi,
    I have an excel file in which i have data for 7000 rows. I only need the data up to a specific row. SO, for that I want to use a macro.

    i want to delete or Clear contents below a specific word (which is "Pro Production") is found in Column A.

    Please help

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete rows or Clear contents below a specific word is found in Column A

    Do either of these help?

    Clear Contents
    Sub kishoremcp()
    Dim lr As Long
    Dim rcell As Range
    
    lr = Cells(Rows.Count, 1).End(xlUp).Row
    
    For Each rcell In Range("A2:A" & lr)
    
        If rcell = "Pro Production" Then
        
            rcell.Offset(1).ClearContents
            
        End If
        
    Next rcell
    
    End Sub
    Delete
    Sub kishoremcpA()
    Dim lr As Long
    Dim rcell As Range
    
    lr = Cells(Rows.Count, 1).End(xlUp).Row
    
    For Each rcell In Range("A2:A" & lr)
    
        If rcell = "Pro Production" Then
        
            rcell.Offset(1).Delete shift:=xlUp
            
        End If
        
    Next rcell
    
    End Sub
    Delete Entire Row
    Sub kishoremcpB()
    Dim lr As Long
    Dim rcell As Range
    
    lr = Cells(Rows.Count, 1).End(xlUp).Row
    
    For Each rcell In Range("A2:A" & lr)
    
        If rcell = "Pro Production" Then
        
            rcell.EntireRow.Offset(1).Delete shift:=xlUp
            
        End If
        
    Next rcell
    
    End Sub

+ 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