Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-05-2017, 06:23 PM
yoyo4 yoyo4 is offline Automatically delete row based on keyword-VBA Windows 10 Automatically delete row based on keyword-VBA Office 2013
Novice
Automatically delete row based on keyword-VBA
 
Join Date: Nov 2017
Posts: 14
yoyo4 is on a distinguished road
Default Automatically delete row based on keyword-VBA

HI,
Need to automatically delete row that contain certain keywords.


Example -:
i have data sheet with 5 column.(Name,Last Name,Company Position,Email Address ,Phone Numbers )
If any of keywords are located in any cell (as part of a word, email, address, job title, company, etc,) need to delete the row automatically.
(keywords-loan,financial,bank,equity)

Thank you.
Reply With Quote
  #2  
Old 12-06-2017, 12:32 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is online now Automatically delete row based on keyword-VBA Windows 7 64bit Automatically delete row based on keyword-VBA Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,779
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

Let me ask again, is this a one-shot task ?
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
  #3  
Old 12-06-2017, 12:56 AM
yoyo4 yoyo4 is offline Automatically delete row based on keyword-VBA Windows 10 Automatically delete row based on keyword-VBA Office 2013
Novice
Automatically delete row based on keyword-VBA
 
Join Date: Nov 2017
Posts: 14
yoyo4 is on a distinguished road
Default

hi,
its not one-shot task.
Reply With Quote
  #4  
Old 12-06-2017, 05:17 AM
NoSparks NoSparks is offline Automatically delete row based on keyword-VBA Windows 7 64bit Automatically delete row based on keyword-VBA Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

perhaps something along the lines of this
Code:
Sub RemoveKeyWordRows()

Dim lr As Long, i As Long, cel As Range, temp As String

Application.ScreenUpdating = False
lr = Cells(Rows.Count, "A").End(xlUp).Row

For i = lr To 2 step -1
    temp = ""
        For Each cel In Range(Cells(i, "A"), Cells(i, "E"))
            temp = temp & cel.Value & " "
        Next cel
        
    '(keywords-loan,financial,bank,equity)
    If InStr(temp, "loan") > 0 Or _
       InStr(temp, "financial") > 0 Or _
       InStr(temp, "bank") > 0 Or _
       InStr(temp, "equity") > 0 _
       Then Rows(i).Delete
Next i
Application.ScreenUpdating = True

End Sub
Instr is case sensitive.

Last edited by NoSparks; 12-06-2017 at 09:55 AM. Reason: step
Reply With Quote
  #5  
Old 12-06-2017, 06:10 AM
Logit Logit is offline Automatically delete row based on keyword-VBA Windows 10 Automatically delete row based on keyword-VBA Office 2007
Expert
 
Join Date: Jan 2017
Posts: 533
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

.
Or maybe :

Code:
Option Explicit

Sub sbDelete_Rows_With_Specific_Data()
Dim lRow As Long
Dim iCntr As Long
Dim iCol As Long
iCol = 26   'add cols here
lRow = 20   'add rows here
For iCol = 1 To 26  'match last col number here with total cols above
    For iCntr = lRow To 1 Step -1
        If Cells(iCntr, iCol) = "loan" Or Cells(iCntr, iCol) = "financial" _
        Or Cells(iCntr, iCol) = "bank" Or Cells(iCntr, iCol) = "equity" Then ' You can change this text
            Rows(iCntr).Delete
        End If
    Next
Next
End Sub
Reply With Quote
Reply

Tags
excel vba, macros



Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically delete row based on keyword-VBA How to delete automatically 500 “Heading 4” and all the contents in this from Navigation? liliaroma Word VBA 4 11-18-2017 07:53 PM
Automatically Delete Slides based on current time Pacman52 PowerPoint 2 07-16-2015 05:30 AM
How to Automatically Add/Delete Columns Based On Information kconnolly Excel 7 04-08-2014 07:23 AM
Find and Delete Rows based on a range damaniam Excel Programming 2 03-12-2014 06:06 AM
Automatically delete row based on keyword-VBA Find keyword in section & delete section donaldadams1951 Word VBA 5 12-03-2013 10:08 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:18 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft