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
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
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
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
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
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
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
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
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
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
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 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 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
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
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
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
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
VBA Macro To Find Text, Offset Column/Row & Copy
I am in the process of writing a VBA code(I should I am fairly new to this code writing!!!).What I need to be able to do is below.(enclosed please find a output in an xls file) What I should be able to do is below:

1.Find the text "Cash(No Listing)(Monthly)"

2. Offset to the 13th Column after that

3.Select the value in this column ,copy the value

4.Go to a row above and move one column to the left i.e.offset (-1,-1) and move 12 column backwards i.e.offset(0,-12)

5.Copy the value in 3 above to this entire range

6.Repeat this process for the entire file

My code is as below.Let me know where am I making a mistake. Just to let you know that this code performs the job well for the first entry i.e in the yellow makde area and doesn't do the job for any further entries .Llooks like I have some problem with the loop but not sure as to whats happening!

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 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
Deleting The Entire Row In VBA
I have a spreadsheet with thounsands of rows. Some of the rows I'd like to delete because thier values are below 5%. I wrote a VBA code, which primary function is to look for a cell and delete the row if the value is less than or equal to 5%. The code looks fine but I get an "Infinite Loop" anytime the first row value is not true. Below is the code,


Sub Delete_Zero_Factors()

Dim i As Integer
Dim CUSIP As String


i = 0

While Not (IsEmpty(ActiveCell.Offset(i, 0).Value))
CUSIP = ActiveCell.Offset(i, 0).Value

Do While (ActiveCell.Offset(i, 1).Value

View Replies!   View Related
Vba Autofill Entire Row
I have recorded a Macro to AutoFill a row in my Excel spreadsheet. The VBA code is very simple and looks like this:

Selection.AutoFill Destination:= Range("D8460:T8460"), Type:=xlFillDefault

I thought I would simply be able to click on another row and re-use the Macro, but this doesn't seem to work, as I get the following error message: AutoFill method of Range class failed.

What do I need to change in my code, so that it will work in any row I choose?

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
VBA Macro To Copy Entire Row To Another Sheet
I have written Macro to copy every row in "sheet1" 24 times into new sheet called "NewSheet". but it keep giving me error message. Actually, I don't know why. Can any one please help.

here is my macro

Sub CopyRowsBook2()

Worksheets.Add().Name = "NewSheet"
' Find the last row of data
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row

' Loop through each row
For x = 2 To FinalRow
Worksheets("sheet1").Cells(x, 1).Select
' Loop to copy every row 24 times
For i = 1 To 24

NextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
Cells(NextRow, 1).Select

Next i


Next x
End Sub

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
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
Find Keyword In Worksheet- Copy Entire Row To Another Worksheet
I am looking for a solution to an otherwise very tedious problem.

I have an Excel WorkBook with 100 WorkSheets.

Each Worksheet has a unique identifying label - "Requirement Number"

Within each worksheet is free form text data of the following categories: ...

View Replies!   View Related
Find Any ??? And Delete Row
i am getting some ??? and ??????? in my excel sheet. i think it's because i am importing some foreign language into excel and it doesn't like it. i was wondering if there is a way to find and delete all these rows. i tried do to a filter for ??? or ??, it simply shows all the results because in the custom autofilter, it has the following:

"Use ? to represent any single charaters"
"Use * to represent any series of characters"

View Replies!   View Related
Find Single Row And Delete Them
I tried to write a script that does following:

I have data that looks like this:


As you can see, mostly every two rows contain same values. But there are some values (here it is 4) that is a "single row".

I want to find every "single row" and delete them. I tried a long time but reached frustration now.

View Replies!   View Related
Find Within Row And Delete Row
I need a macro to find anywhere in column A a + (plus sign) and delete that row.

Example if P+A is in a row in column A then the row is deleted, and similarly if just J+ is in column A then the row is deleted.

View Replies!   View Related
Find Function: Give The VRow Variable The Value Or The Row That The Text From Text Box Is On
I am using the following code.

Function VLOOKUPRow()
Dim SV As Object
SV = "UserFormAppend.TextBoxInvID.Text"
VRow = Columns(1). Find(What:="SV", After:= Cells(1, 1), _
LookIn:=xlValues, SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, MatchCase:=True).Row
MsgBox (VRow)
End Function

I am trying to give the VRow variable the value or the row that The text from my text box is on. How do you make the what look for a variable. I can get it to work if i put a constent in the what. how to make the what look for a variable. I'm new at this forum thing so im not quite sure how to check for answers.

View Replies!   View Related
Find Duplicate Data And Delete Row
compare and find exact matches b/w the data in columns J and K in the attached csv file. I would simply like all rows with exact matches to be hidden. I can simply change any code to reflect something like


later if necessary.

View Replies!   View Related
Find And Delete Rows In Vba
Basically i have a column which runs like this:

Company Name:


Basically, what I am after doing is getting a script to look through that column and delete any rows that do not have "Name1" in Column A.

So far, i've sorted the column so all the blank cells appear at the top, and the "Name1" cells appear at the bottom. Now what I was going to do was use a loop, and I got as far as this before becoming confused .....

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 All Cell Values In Column And Delete Row
My code is always failing on the findnext method. I'm thinking that the findnext method fails because it loses it's cell reference when the row gets deleted.

Sub findwbs()
Dim rngFind As Range
Dim strFirstAddress As String

View Replies!   View Related
Find The Last Row Without Data In Columns E And F And Delete The 10 Rows Below Them
I'm trying to come up with a formula to find the last row without any data in columns E and F and delete the 10 rows below them. Is there a way to do this?

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
VBA - If Then Delete Row
I am trying to write a code that checks a column, if it doesnt fit the criteria, then delete the entire row.
My VBA is very rusty.

x=6 ( column F)

if len(sheets("sheet1").cells(x,1)

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