Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Excel


VBA - Find Text And Delete Entire Row

VBA for finding text through an Excel SS and deleting the entire row if the text is found.

For example if the string "STAD LLL" is present in any cell in any string position the entire row is then deleted.

View Complete Thread with Replies

Sponsored Links:

Related Forum Messages:
Find Value & Delete Entire Row
I've a worksheet containing a list of items some of which need deleting. These are identified from a particular range where users input "y" to notifiy the record can be removed. The code below works just fine if all I do is Clear the cells containing "y". However using: Range(rCell.Address).EntireRow.Delete

the macro stops after deleting the first item. It suddenly believes there aren't any further items to delete and Ends. There are no error messages returned. Entire macros is below.

Sub unreg_report()
Dim rRange As Range, rCell As Range
Set rRange = Range("unreg_list").SpecialCells _
(xlCellTypeConstants, xlTextValues)
For Each rCell In rRange
If rCell = "y" Then

End If
Next rCell
End Sub

View Replies!   View Related
Delete The Entire Row That Has The Text Pc.
I use the code below to delete the entire row that has the Text "Pc." in it. How can I make this delete the row with "Pc." plus the next row?

Sub PL()
Dim i As Long

For i = Cells(Rows.Count, "A").End(xlUp).Row To 1 Step -1
If InStr(Cells(i, "A").Text, "Pc.") Then
Cells(i, "A").EntireRow.Delete
End If
Next i

End Sub

View Replies!   View Related
Delete Entire Row If Cell In Column Contains Certain Text
Delete entire Row if cell in column contains "Dog" in it.?



so after it would look like this


View Replies!   View Related
How To Find A Specific Text And Copy This Entire Row
I tried to writer my code myself but I have a long way to go. Here is what I must do for my case:

I want a macro to find the row that include a specific text (For example "SMSC") in a range (A1:A100) then copy this entire row below the cell which has the value "OTHERS". That is, if there are 10 pieces of "SMSC" so these rows including "SMSC" should be listed below the cell "OTHERS"

View Replies!   View Related
Find Text Delete Values
I need to change the value of cells if column I contains the word error ....

View Replies!   View Related
Find Text & Delete All Rows Below
I have a report that comes in a txt file. After importing into excel i am left with a bunch of garbage that i dont need. This report is anywhere from 5-15 pages depending on how much product was made that shift. I only need the information off of the 1st page. My question is how can i Find the first occurance of specific text (Site) (will be in column A) and have it select that row and all rows below and delete them.
My biggest issue is the first page can be anywhere from 40-60 rows so I need to find the text (Site) and delete everything below it, which could be anywhere from 500-1500 rows.

View Replies!   View Related
Find Text In Column & Delete All Rows Below
I am trying to create a macro that will delete everything below a certain word.

The code I tried to use is the following. This produced an error:

If Range(Cells(1, 1), Cells(180, 1)). Find(" Interest Expense").Row = 0 Then
iStart = Range(Cells(1, 1), Cells(180, 1)).Find(" NET INCOME").Row + 1
iStart = Range(Cells(1, 1), Cells(180, 1)).Find(" Interest Expense").Row + 1
End If
Rows(iStart & ":" & FinalRow).Delete shift:=xlUp

View Replies!   View Related
Find Part Text On All Sheets & Delete The Column
I am trying to move through the worksheets and delete all columns with "Accession" in contained in them. I have to do this with an external macro as the spreadsheet with the data is created from another program. I tried this and get an 'Object or With block variable not set' error and the debug highlights the Cells. Find line of the code.

Also, the number of columns could be variable within the spreadsheet as it is compiled by the other program.

Sub DelAccessionNum()
Dim Wrkst As Worksheet
For Each Wrkst In ActiveWorkbook.Worksheets
Cells.Find(What:="Accession", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False _
, SearchFormat:=False).Activate
On Error Goto Completed:
Selection.EntireColumn.Delete Shift:=xlToLeft
End Sub

View Replies!   View Related
Delete Entire Row If
How would i search the entier worksheet im in, looking at column b only, and delete the entire row if i find the word Date in it.

View Replies!   View Related
Delete Entire Row
when i delete the entirerow, it shifts the rows up (which is what I want) but it skips that row when it does.

so if I have 2 blank cells together it will delete the 1st and leave the 2nd blank.

Sub ()
Dim myrange As Range
Set myrange = ("a:a")
For Each c In myrange
If c.Value = "" Or c.Value <= 5 Then
End If

End Sub

View Replies!   View Related
Delete Entire Row Of An Array
I want to know if there is a way to delete an entire row from an array? I have a 2 dimensional array and I want to loop through the elements in the first column and delete an entire row based on some conditions. Since the number of rows are too many usual looping takes a long time so I want to use an array.

View Replies!   View Related
Delete An Entire Row If Condition Is Not Met
I'm working on Outlook 2003 and Word 2000 which are not compatible. I have an
Excel Sheet which are my contacts from Outlook and I want to re-work it to
have only a certain category left.

I need a macro that does
- search a certain column
- deletes the row if it does NOT find a certain condition

Ideal would be a little pop up window to enter which category I want left.

View Replies!   View Related
VBA- Delete Entire Row Which Has The Highlighted ...
i have over around 1500 pfolios in Col A, i need macro that will delete entire row which has the highlighted pfolios. Now i tried advanced filter which would work but the date in Col A6 will change every month, so dont want to go down that road, is there alternative option other than advanced filter ..

View Replies!   View Related
Lookup Value, If Not There, Delete Entire Row
I am trying to Lookup multiple values (can't be done manually) in one report (Report 2) from another (Report 1).

If the value from Report 1 isn't present in Report 2, I want the entire row the value is found in (From Report 1) deleted.

View Replies!   View Related
If Column B Is Blank Delete Entire Row
I am using the following macro to delete "completely empty" rows. I also need to delete some rows if a cell in column B has no value. How would I change this macro?
' DeleteBlankRows

Dim r As Long
Dim C As Range
Dim Rng As Range

On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

If Selection.Rows.Count > 1 Then
Set Rng = Selection
Set Rng = ActiveSheet.UsedRange.Rows
End If
For r = Rng.Rows.Count To 1 Step -1
If Application.WorksheetFunction.CountA(Rng.Rows(r).EntireRow) = 0 Then
End If
Next r


View Replies!   View Related
Delete Entire Row Based On Selection
I have a worksheet where I have restricted the users from scrolling around beyond a certain range.

Because of that the user is prevented from selecting an entire row.
There are some cases where the user should be able to delete entire row or range of rows.

How can I allow them to select say cells "C17:C35" [they would just hoghlight the range] and hit ctrl+d; which would trigger a macro and the macro in turn would delete all the rows in that selection [rows 17 through 35]?

I know some basic codes for deleting entire rows, but I don't know how to read first and last row of the selection under Target property.

View Replies!   View Related
Delete Entire Row Based On A Condition
I have a problem deleting rows based on a condition, i didn't know how to use offset method.

i'm using a table like this one :

1 Main design1 FFR0
2 Extra design2 FFR0
3 Main design3 FFR0
4 Extra design4 FFR0
n Main designn FFR0

I want to delete entire row if "FFR0" in column C exists in a row beginning by "EXTRA" (column A)

View Replies!   View Related
Efficient Way To Delete Entire Rows Using Vba
in a selected columnar range.

I want to write a fairly simple, fast macro to examine a selected range and simply delete the row for each blank cell that it finds in that range.

I have read around that loops aren't necessarily that fast and some of these ranges could be 1000s of rows long...

way to write something like this in VBA?

View Replies!   View Related
Delete Entire Row If Cell Equals
I have a row range 5:20004. In that row range column R may have 'QLD' in the cell.

I am trying to delete all rows within that range that have QLD in column R or delete the row if R <> 'NSW' (would be a better way just in case there is something other than QLD)

to do this on opening the file automatically.

View Replies!   View Related
Delete Entire Row If Specified Word Exist
In range A1:A300 I have a lotof words. What I want is to delete entire row if the cell value is Open date

View Replies!   View Related
Search And Delete Entire Columns
I have Column Headers in Row 1 (except column A), What I need to do is write a Macro or some code to

1.Search the entire row 1 for column headers containing the suffix _CSV and delete the entire columns.
2.Shift all remaining columns to the left so no blank columns exist. (There is a time stamp in row A that I wish to keep where it is.)

Next I would like a separate routine to sort the columns in the order of a Pre-defined list that I specify in a range. For example the list of column headers reside in the Range (A1:A200)

View Replies!   View Related
Delete Entire Row If Row Contains Cells That Are Empty
I've been looking for a couple of hours to try and find VBA to delete entire row if that row contains cells that are empty.

View Replies!   View Related
If Cell Contains The Word Delete Entire Row
Looking to write a macro to delete an entire row if the word GROWTH is found in any cell under Column C.

View Replies!   View Related
Delete Entire Row If Cell Contains String
I need to write a macro that will search column A and find the word hospital or HOSPITAL and if found delete the entire row. The code I have below will do this ONLY if hospital or HOSPITAL is the only word in the cell. However in my column A there are numerous words in each cell i.e Saint Mary's Hospital.

Sub KillRows()
Dim rngNew As Range
Dim rngDelete As Range
Dim aCell As Range
Dim lastrow As Long
Set rngDelete = Nothing
Set rngNew = Worksheets("Sheet1").Range("A1", Range("A65536").End(xlUp))
For Each aCell In Selection
Select Case aCell.Value...........

View Replies!   View Related
Delete Entire Row Through Macro Button And VB Code
How can we delete entire row using VB Code.

say example i want to delete a row having name 'Anis' by clicking on a buttton

is this possible?

View Replies!   View Related
Macro To Check For Information And Delete Entire Row
My workbook is set up such that column B has dates (starting in B11 and going to B1200). C11:Z1200 has data that correspondes to the date in Column B. There are a lot of dates that don't have data. For example, row 15, there is a date in B15 but no other information for the remainder of row 15.

I'm trying to write a macro that will delete entire rows for the dates in which there is no data. So, I'm presuming that it would search C15:Z15, if there is not information in these cells, then delete row 15.

Row 16 becomes 15 when you delete 15.. I don't know how to get around this.

View Replies!   View Related
Delete Entire Row Depending On The Contents Of A Cell
I'm trying to write a procedure which will search the contents of Column B of my worksheet for the word "Total". Whenever the word "Total" is found in a cell within Column B, the entire row should be deleted.

View Replies!   View Related
Delete Entire Rows Not Meeting Criteria
Excel Range A1 - D500. Data located in column C. I would like to delete the rows in this spread sheet that do not contain any of the following 3 prefixes of part numbers from column C: X-SXP, X-SCM and X-SBP. There are many part numbers but only parts with these 3 prefixes are needed. Part numbers are 10 characters long after the prefix. If any additional information is needed, let me know.

I viewed the Delete Rows Meeting Conditions thread, but the input value in that code is for what you want to delete, and I need to delete everything not meeting the data I want to keep, which is about 30 different part numbers. Also, that appeared to only offer one input and not 3.

View Replies!   View Related
Delete Entire Row Based On A Cell Color
I used this macro to find the duplicates in column B:

Sub KryDups()
ScreenUpdating = False
FirstItem = ActiveCell.Value
SecondItem = ActiveCell. Offset(1, 0).Value
Offsetcount = 1
Do While ActiveCell <> ""
If FirstItem = SecondItem Then
ActiveCell.Offset(Offsetcount, 0).Interior.Color = RGB(255, 0, 0)
Offsetcount = Offsetcount + 1
SecondItem = ActiveCell.Offset(Offsetcount, 0).Value
ActiveCell.Offset(Offsetcount, 0).Select
FirstItem = ActiveCell.Value
SecondItem = ActiveCell.Offset(1, 0).Value
Offsetcount = 1
End If
ScreenUpdating = True
End Sub

The duplucate cells are now red in color. (RGB(255, 0, 0)). How do I now code VB to delete the rows in column B where the cell color is red? Here is some of the code that I tried:................

View Replies!   View Related
Search Column A For Blank Cells And Delete Entire Row
I have tried several methods to delete the entire row if the cell in column 'A' is blank ...

View Replies!   View Related
VBA Delete Entire Rows Based On The Value Of Single Cell
I know it can delete entire rows based on the value of single cell, I just don't know how to do it. So what I need is a macro that will delete an entire row if the value in a particular column = 0.

More details: ....

View Replies!   View Related
Macro To Delete Entire Rows If Certain Cells Are Empty
I'd like help in creating a macro that deletes an entire row that has emtpy cells in col B, C & D in the same row.

So for example if I have empty cells in b3,c3 & d3 I'd like the row deleted.

I've used the code below for just column B but I need to include column C & D as well. I tried putting Columns("B:D") but it deletes everything.

View Replies!   View Related
Delete Entire Row If Cell In Column Starts With Asterisk
I'm using the following code to delete rows that I don't want to include and I've ran into some more things that need to be deleted...

For lLoop = RngCol.Rows.Count To 2 Step -1
Select Case RngCol(lLoop, 1)
Case " Date:", "Skill:", "Agent Name", "~*", "*Train*"
RngCol(lLoop, 1).EntireRow.Delete
End Select
Next lLoop

An example of "~*" would be: ***SICARII***
An example of "*Train*" would be: Ozgrid Train1

It's not recognizing these new cases. Do I have to utilize FIND? (since CTRL+F does work with the given cases)

View Replies!   View Related
Find Entire Cells Only
I need a macro that does a find from cell C7 to C954 that has a 0 in the "Find what:" and does it with the "Find entire cells only" checked off.

Is this possible. I have searched the forums and not found this yet.

View Replies!   View Related
Macro To Delete An Entire Row If A Duplicate Entry Appears Only In A Certain Column.
Is there a macro to delete an entire row if a duplicate entry appears only in a certain column.

1. Look for the column header with the name "File Number"
2. Anytime the same number under the "File Number" column appears more than once in that column, keep the row that contains first occurrence of that number buy delete the entire row anytime that number is repeated in another row in that same column.

This is regardless of what is contained in the other columns. For example..let's say these cells contained this data...

B1 - UTE00225
B2 - UTE00546
B3 - UTE65513
B4 - UTE00225
B5 - UTE00225

In this case, I would want to keep rows 1, 2, and 3. But, I would want to delete rows 4 & 5 because the number "UTE00225" has already appeared first in B1. I'm using Excel 2003.

View Replies!   View Related
Delete Entire Rows Where 1 Column Meets Multiple Criteria
I need create a macro to perform the following - I don't know if it needs to be an Excel macro or via VB. This is to speed a process up and eliminate any spreadsheet messing around for our "admin" staff - they are not good with excel at all!

So, I have a daily/weekly down load of a spreadsheet (exported from access).

* I want to copy the values of column AK to A
* Then delete all entries in column D that equal 19, 20 and 6
* Then delete all entries in column AL that equal "A","B","C" or "D" but not "E","F" or "G"
* Then delete entire rows where the value in column A is a duplicate within the list

I will call this spreadsheet, for the purpose of this exercise, the "Master". I now have another spreadsheet with values in that should relate to values in either (or both) columns A and B in the "Master". I need Spreadsheet 2 values to be highlighted as cross checked in the "Master" and then all those in the "Master" that do not appear in the 2nd S/S will be normal white cells thus showing that they need to be chased by our Admin staff.

View Replies!   View Related
Find Value In Column & Copy Entire Row
way to search for a value in a cell (an unique one) using an input box and then if the value is found copying the whole row of the cell onto a new worksheet in the next available row within a table.

I am currently using the following archaic codes:

x$ = InputBox("Please Enter Catalogue Number")

For i = 4 To 500

If Sheet2.Cells(i, 1) = x$ Or Sheet2.Cells(i, 7) = x$ Or Sheet2.Cells(i, 8) = x$ Or Sheet2.Cells(i, 9) = x$ Then

Sheet1.Cells(6, 1) = Sheet2.Cells(i, 1)
Sheet1.Cells(6, 2) = Sheet2.Cells(i, 2)
Sheet1.Cells(6, 3) = Sheet2.Cells(i, 3)
Sheet1.Cells(6, 4) = Sheet2.Cells(i, 4)
Sheet1.Cells(6, 5) = Sheet2.Cells(i, 5)
Sheet1.Cells(6, 6) = Sheet2.Cells(i, 6)
End If

Next i

End Sub

this has the problem that i can't fit it to the next available row and have to be specific for each row.

it would also be great if i could put a messagebox in cases where the data is not found, basically saying that the item does not exist and if a simple excel Ctrl+F button or something similar could be attached to the msgbox so that the item can be searched and then added to the next available row.

View Replies!   View Related
Find Match Then Copy Entire Row
Random values will be pasted into sheet1. I a looking for a macro that will look for a match to the values in sheet1 column A in Sheet2 Column A. When a match is found it will paste the entire row from Sheet2 to sheet#3

See the example. Note: the match will always be an exact match.

View Replies!   View Related
Find & Replace - Entire Workbook With A Twist
I have a workbook with many different worksheets containing data. I am looking to find a certain city name in each worksheet and then replace the region name immediately to the left of the city name.



Region City


Region City

View Replies!   View Related
Find 1 Character And Replace Entire Cell
how I could find 1 character and replace the entire cell. For example, it would find "<12", "<3", and "<32" based on "<" and then replaced that entire cell with "N/A".

View Replies!   View Related
Find Match Cells And UnLock Entire Row
I am trying to figure out how to write a program that will: Match the date in cell H3 (which will show the current date) with a range of dates in column A then once this date is found the entire row will UNLOCK or allow me to update cells with data from another excel worksheet. If this is unclear or I need to post additional information let me know.

View Replies!   View Related
Needing To Find Largest Value In Array, Then Return Entire Row Associated With Result
I have a table with subtotals that I need to find the largest value for the subtotal results and then return the cell contents for the corresponding row.

I have attempted to use the hlookup function, but keep getting a #ref error (probably because I am just not that familiar with the entire formula requirements).

I attempted to nest in the 'largest' function to the lookup function, but have so far been stymied....

View Replies!   View Related
Add Text To Entire List
I have an excel list in one column of all my AP vendors and I want to add text to the bottom of the vendors name, such as:

Currently looks like this:

Office Depot
Orchard Supply

I Would like it to look like this:

Office Depot
FY 09/10
FY 09/10
Orchard Supply
FY 09/10

So basically I want to add the FY 09/10 to the bottom for the entire list of vendors. On top of that, all though it's not a critical, I would like to have the FY 09/10 be a different size and boldness.

this is to do a mail merge for labels in word

View Replies!   View Related
Append Text To Entire Column
I have a list of number in a column that there is over 22,000 is there a away I can add ".jpg" ad the end of each number?

View Replies!   View Related
If Text Is Found On Two Sheets, Copy Entire Row
I have one master worksheet with 1000 ID's. I also have 10 other spreadsheets with 1000 ID's. I need my macro to use the master worksheet and identify where the IDs are located among the 10 spreadsheets. If there is a match, then my macro should copy the entire row and place it in an output file (another spreadsheet).

The following code only tests the master worksheet and three other sheets (one being null/error is ID not found).

Sub Macro5()
' Macro5 Macro
Dim Raw, Mix1, Mix2, error As Excel.Worksheet
Set Raw = Sheets("RAW_DATA")
Set Mix1 = Sheets("Mix1")
Set Mix2 = Sheets("Mix2")
Set error = Sheets("error")
For x = 1 To 1000
For y = 1 To 1000
If Raw.Cells(x, 1) = Mix1.Cells(y, 1) Then.................

View Replies!   View Related
Catch An Error And Reset The Entire Code To The Very Beginning And Skip That Entire Entry
I want to catch an error and reset the entire code to the very beginning and skip that entire entry. When I use "Next fieldSheetName" I get "Next without For," error 1004. Searches tell me I have an open block somewhere, but that's not true. Removing that statement (and having the loop iterate as normal) has no error at all.

Dim employeeName As String
Dim fieldMax, x, y As Byte ' Counters mostly
Dim workedHours, fieldSheetName As Integer

fieldMax = 204 ' Row number to stop on in the field time sheet
row = 4 ' Row specification for field time sheet. Begin at row 4 to ignore headers
' and start on the first name. This should not be changed!
Col = 3 ' Start at column 3 then increase by one to start going to next time entry

For fieldSheetName = 4 To fieldMax Step 8 ' This is our MAIN loop. It iterates from 0 to fieldMax, which is 204...........

View Replies!   View Related
Paste A Word In Front Of Text That Is Already Residing In Cell Throughout An Entire Column
I am trying to do, is paste a word in front of text that is already residing in cell throughout an entire column, and then automate this process by creating a macro that will do the same thing for me throughout an entire column. To best explain this, it woudl be like if you have a column 100 rows/cells long, and every cell already contains data. I need to insert something in front of what lies within each cell.

View Replies!   View Related
Delete Entire Rows Where Column IV Contains "x"
I have the following code to delete entire rows where column IV contains "x".

With ThisWorkbook.Sheets("Sheet3")
With .Range("IT1", .Range("IV" & Rows.Count).End(xlUp))
.AutoFilter Field:=1, Criteria1:="x"
End With
End With

End Sub
[/Code ]

For a reason that I can't see, it is deleting not only the row that contains the "x" (there is never more than one row with an "x" in column IV), but also the row immediately below it.

View Replies!   View Related
Search For Text Delete This Row And Delete The Row For Every Instance
I have an formula if statement that returns "deletethisrow" if the test is true.

For every occurence of "deletethisrow" I want to delete the row. The number instances will be variable each time I run the file. So maybe it will find that string, maybe it will find 10 instances. I want to do some kind of loop that won't error out when it cannot find "deletethisrow", but will delete the rows for each instance where it does find this string.

I know it was verbose, but if I just do a loop for a fixed number of loops it will error out if it runs out of rows to delete.

View Replies!   View Related
Delete Entire Row If Column A Matches Column D
Does anyone have a macro that will delete entire row if column a matches column d

View Replies!   View Related
Copyright 2005-08, All rights reserved