Delete Entire Row If Cell Contains String

Jan 30, 2008

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))
rngNew.Select
For Each aCell In Selection
Select Case aCell.Value...........

View 5 Replies


ADVERTISEMENT

Delete Entire Column If Row Has Certain String?

May 5, 2014

I have fixed headers on row 16, from columns A-AC.

I want to be able to delete the entire column, if the row has a certain string, such as "Chart ID" .

I also want to expand it to include other strings such as "Month" and "Source" . So if it contains any of these words, the columns should be deleted. It should be an exact match (as other headers contain the word "month").

View 12 Replies View Related

Excel 2010 :: Copy Entire Row If Cell Contains Specific String

Apr 5, 2012

I am a total newb to excel and vb, and only have minimal experience in embedded C.

I have a very large spreadsheet with 9 columns and the max number of rows that excel supports (office 2010).

What I want to do is copy the entire row of data IF a cell in that row contains a specific string I'm interested in.

If it's necessary, the column that contains the values that would trigger a row copy would be column C and the data would be pasted onto a new sheet.

View 1 Replies View Related

How To Delete ENTIRE Row If Only One Cell Is Duplicated

Jun 15, 2011

I have a file with 238 rows and 10 columns (see file attached) Column G include phone numbers, some phone numbers are duplicated.

How can I use a macro (I must do it with a macro) to delete the ENTIRE row if the value in column G is the same in other row?

For example: look at rows 2 and 3 : the value in column G2 and G3 is the same, therefor delete row 3

(and if the value in G4 was also the same, then delete also row 4, and so on..)

View 10 Replies View Related

Delete Entire Row If Cell Contains 3 Characters

Sep 5, 2013

I can't get this code to work which I want to delete the entire row if the cell in the specified range contains only 3 characters;

Code:

Sub CharCount()
Dim cell As Range
Dim bottomK As Integer
bottomK = Range("D" & Rows.Count).End(xlUp).Row
Dim rng As Range
Set rng = Range("D2:D" & bottomK)
For Each cell In rng
If Len(cell) = 3 Then
EntireRow(bottomK).Delete
End If
Next cell
End Sub

View 6 Replies View Related

How To Delete Entire Row That Has Blank Cell

May 14, 2014

VBA codes in filtering blanks.

Here is a screenshot, and what i want to do is to delete the entire row that has a blank cell. In which here, the 5th row, 7th row and 9th row.

View 5 Replies View Related

If Cell Contains The Word Delete Entire Row

Dec 10, 2008

Looking to write a macro to delete an entire row if the word GROWTH is found in any cell under Column C.

View 9 Replies View Related

Delete Entire Row If Cell Equals

Oct 1, 2007

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 9 Replies View Related

Delete Entire Row If Cell Greater Than Or Equal To 1?

Jul 12, 2012

i have table of values if any value in the coulomb G and I greater than or equal to 1 the entire row must be deleted how can i do this ?

View 4 Replies View Related

Delete Entire Row From Excel Table When Cell Not Zero?

Dec 27, 2012

How to delete the entire row if the cell value of the "D" column is greater then zero (not containing "0").

View 8 Replies View Related

VBA Coding - If Cell Value Equals To 0 Then Delete Entire Row

Mar 19, 2014

Basically, I have a table of data and I want to make a VBA coding so that Any row with "cell value = 0 in column C" will be deleted.

But I can't get my code working and i don't know why. There's no error pop up either.

View 2 Replies View Related

Delete Entire Row Depending On The Contents Of A Cell

Jan 20, 2009

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 5 Replies View Related

Cut / Paste And Delete Entire Row Based On Cell Value

Dec 13, 2013

I have got a vacancy tracker spreadsheet and I need it to move an entire row from the 'Open' to the 'Closed' sheet based on the status in column K, i.e. 'Closed +', 'Closed -', and 'Closed + Achieve'. Once this has been done I want it to delete the entire row in the 'Open' sheet. At the moment it just cuts the entire row and then it is left blank and when I delete it manually the macro stops working completely.

Also I can only get it to move 'Closed +' and 'Closed -' and seem not to be able to add a command to move 'Closed + Achieve' rows.

This is what I have got so far:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Columns("K")) Is Nothing Then Exit Sub
Application.EnableEvents = False
If Target.Value = "Closed +" Then

[Code] .......

View 2 Replies View Related

Delete Entire Row Based On A Cell Color

Mar 9, 2007

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
Else
ActiveCell.Offset(Offsetcount, 0).Select
FirstItem = ActiveCell.Value
SecondItem = ActiveCell.Offset(1, 0).Value
Offsetcount = 1
End If
Loop
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 5 Replies View Related

Delete Entire Row If Cell In Column Contains Certain Text

Mar 26, 2007

Delete entire Row if cell in column contains "Dog" in it.?

Example,

duck321
dog123
cat123
dog123
duck321
cat123

so after it would look like this

duck321
cat123
duck321
cat123

View 9 Replies View Related

If Cell In Column Is Blank / Unpopulated Delete Entire Row?

Oct 16, 2013

If cells in column A3:A10000 are blank / unpopulated I would like to delete the blank rows.

View 6 Replies View Related

VBA Delete Entire Rows Based On The Value Of Single Cell

Jun 10, 2009

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 9 Replies View Related

Delete Entire Row If Cell In Column Starts With Asterisk

May 9, 2008

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 4 Replies View Related

VBA Macro To Delete Entire Column When Background Cell Color Is Red

May 17, 2013

with performing the following tasks with VBA:

1). For each cell that in the range that has a Red background delete the entire column
I have attached a sample spreadsheet where I have tried to do this. It's not quite working. It does not seem to work when there are RED cells next to each other.

I know that I can do a simple thing like column("A:A"), but I'd rather have it in a loop as in the sample code, in case the columns change in the future.

2). The second task is to delete the rows in the spreadsheet where the first cell in the row is a blank.

View 4 Replies View Related

Macro Code To Delete Entire Row If Cell In Column Is Equal To Value

May 7, 2014

I need an easy code that searches all of column A and deletes the entire row if the cell has the value "-". It needs to find the last row of data using something like LastRow = Range("A" & Rows.Count).End(xlUp).Row

View 4 Replies View Related

Delete Row If Cell Does Not Contain Certain String

Oct 23, 2013

I want a macro to look at column G and if a cell in column G does NOT contain "Test Case" anywhere in the cell then delete the row. So for example G5 might be "Test Case/Others" - I would not want this row deleted.

View 3 Replies View Related

Delete String After Last Space In A Cell

May 4, 2007

I am interested in some sort of macro or formula that will strip all of the characters in a cell that come after that last space. My difficulty lies in that the string isn't a constant character count nor is the string always the same.

American Legion Post 8754 Hartford
YWCA Canton

I would like for it to say:
American Legion Post 8754
YWCA

View 10 Replies View Related

Delete A Cell If It Contains Specific Text String?

Oct 19, 2012

I need A VBA that will delete a cell if it contains a specific text string

As long as the cell content is deleted, I can do the rest that needs to be done.

View 4 Replies View Related

Delete Row If Cell Text Matches Known String

May 21, 2008

I have an excel file, and on some rows, the "B" column contains the text " Total:" (it does have a leading space). I would like to loop through the first 200 rows (maximum length of the file) and delete all the rows that contain " Total:" in column "B". I have tried:

For i = 1 To 200
range("B" & i).activate
If range("B" & i).value = " Total:" Then
rows(activecell.row).select
selection.delete shift:=xlUp
End If
Next i

When I step through that code, it just skips over the IF function as if B1 does not equal " Witness:"

View 3 Replies View Related

Match Entire String

Dec 28, 2008

I am trying to use cells.find to find a cell containing "Date". However, it also finds cells with "Start Date" and "End Date" and any other instance of the word date. Is there anyway to make it match ONLY IF the cell contains EXACTLY "Date" and nothing else?

View 4 Replies View Related

Copy Entire Row If Cells In Row Contains Specific String

Apr 3, 2013

I'm trying to copy entire row from sheet "source" to sheet "output".

Condition: If cell or cells in range (E7: lastcoll, lastrow) value is "A" then copy entire row.

Find the excel template in attachment.

My problem is that my macro is copying particular row, as many times as many "A" finds.

I want to copy entire row just once doesn't matter how many cells with "A" are in particular row.

VB:
'function to find last column a change letter of column to number
Private Function ColLetter(LastCol)
ColLetter = Split(Cells(1, LastCol).Address, "$")(1)
End Function

[Code] .....

copyROW.xlsm

View 3 Replies View Related

Delete Entire Row If

Oct 28, 2008

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 9 Replies View Related

Delete Entire Row

Sep 24, 2006

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
c.EntireRow.Delete
End If
Next

End Sub

View 5 Replies View Related

Macro Seems To Make Entire Text String In Cells Bold

Aug 1, 2014

I have the following code:

[Code] ..........

However, whenever I run the code, if there's even on word that is bold in the cell, then the entire text string in the cell turns bold. How can I stop this from happening? i want to keep the format of the text string the same, only remove and replace the items listed in the code.

View 4 Replies View Related

Delete An Entire Row If Condition Is Not Met

May 3, 2006

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 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved