Delete The Whole Row If Any Cell In A Certain Column Has Certain Text
Jul 1, 2009
Note: The "Bread Type" column will ALWAYS be in row 1, BUT will ALWAYS be in a different column letter, so I would like this macro to find the "Bread Type" column by name rather than by column number. All criteria should NOT be case sensitive.
In the example below, rows 2, 4 & 5, have the text "Wheat" or "Rye" in the "Bread Type" column, therefore, all 3 of these entire rows should be deleted. Yes, I do mean the ENTIRE row, wipe these rows off the face of the earth
I'm using Excel 2010). I have column I, which is the sum of columns A and B (first and last names of patrons), and I have used conditional formatting to identify all duplicates in column I with red text. I would now like a macro to find red text in column I and then delete the corresponding rows.
I've been looking around on the web for a while and have cobbled together this code stolen from other people's macros:
[Code] ....
When I run it, I get the following error:
Run-time error '1004':Application-defined or object-defined error
Excel doc is called "stupid mailing list.xlsm", sheet I want to run the macro on is called "voters".
i would like to be able to use a macro that will delete all columns in the sheet that do not contain one of 5 pieces of text in cells 1 to 20.
It is driving me mad, i have managed to find macros that delete empty columns, but they do not remove the columns that do not contain any of the 5 words. often the cells are empty down to row 5, when the data starts
I have a spreedsheet that has both numerical data and text data in column "A". I need to delete all the rows that have text in Column A and keep the rows that have numerical data.
I receive thousands of raw data every week as shown in the excel sheet {raw data}
I would like to use a macro that could automatically sort the raw data like the format in the excel sheet {template}
For example:
Looking at the raw data and compare with the template, i would have to delete the whole columns that have (BU_CODE , EAN_CODE, SUPPLIER_CODE, SUPPLIER_NAME , BRAND_NAME, and SUB_CATEGORY_CODE) and add in columns and name it as Principal, Cateogry , Brand and range).
I want to delete any/all rows from a worksheet (named UK) which have the word "VAN" in column P. I have tried using a 'For Each... Next statement' in a macro, but always get a debug box "Run Time Error '91' Object variable or With block variable not set". What am I doing wrong? my code follows
Sheets("UK").Select Dim cell As Range For Each cell In Worksheets("UK").Range("P10:P200").Cells Cells. Find(What:="VAN", _ After:=ActiveCell, _ LookIn:=xlFormulas, _ LookAt:=xlPart, _ SearchOrder:=xlByColumns, _ SearchDirection:=xlNext, _ MatchCase:=False, _ SearchFormat:=False).Activate Selection.EntireRow.Delete Next
I have a column of data with letters in each cell, no numerical, only alpha. Now, some of those cells contain the letters "adj sub" as part of the text string in each cell. "Adj sub" is always at the beginning of the text string. As an example, a cell will look like this - "adj sub mhm". I want to delete rows whose cell description does not contain "adj sub" as part of the text in the cell.
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 Completed: Next End Sub
I have a long spreadsheet and want to remove rows of information from it if cells contain a specific word. If the cell in column A contains the word "district" or "borough" anywhere in the string of text and irrespective of the case I need to delete the whole row.
I'm looking for code to find a copy of the text in cell AH3 in a range AH7:AH100 then delete all copies of the text in that range AH7:AH100 leaving other cells in that range which contain different text intact.
I need to cycle and extract row data from the A, B and D columns and copy it into another worksheet while maintaining the copied data structure. Right now I am manually selecting the data....
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:"
I would like to create a VBA code where it will delete the entire column if the cell value is equal to value in D2
For example:
Sub Delete_Columns() Dim rng As Range, cell As Range, del As Range Set rng = Intersect(Range("G2:S43"), ActiveSheet.UsedRange)
For Each cell In rng If (cell.Value) = D2 _ Then If del Is Nothing Then Set del = cell Else: Set del = Union(del, cell) End If End If Next cell On Error Resume Next del.EntireColumn.Delete End Sub
======
But I think this line is wrong but I am not sure how to fix it - If (cell.Value) = D2 _
I have data that covers multiple rows that I need to merge into one row.
Header:| InvoiceNumber | Type | Name Row1: | 1000 | Payor | Doe, John Row2: | 1000 | Payor | Smith, Mary Row3:| 1000 | Payee| Jones, Henry Row4:| 1000 | Payee | Jones, Bob
I need to get those four example rows down to one row such as:
Header | InvoiceNumber | Payor | Payee Row1: | 1000 | Doe, John & Smith, Mary | Jones, Henry & Jones, Bob
The number of payor/payee can vary between 1 and several. I need some way to loop through and keep appending the names in one cell separated by a "&". And then deleting all the duplicate rows (based on InvoiceNumber).
On the sheet titled Price List, in row 1, I have an =IFERROR(HLOOKUP( formula to show what I need. The Data Pull sheet can be updated using a third party software, and retailers can be added or deleted. The purpose is that if a retailer is deleted from the Data Pull sheet, it will automatically be removed from the list on the Price List sheet, rather than just showing a bunch of N/A's in every cell. Then if it is re-added in the future, it will repopulate on the Price List sheet.
The formula I have in row 1 is my manual way of showing whether or not the retailer was deleted. If it contains EXCLUDE, you can go in and manually delete the column. However, I would rather have a macro do this.
way to find blank cells in a column(s) and delete the rows corresponding to the cell number. I found this code in one of the previous threads on ozgrid but it just doesnt work for me because it is slowing me down. Please help (I am working on around 60000 rows in Excel 2007)
Sub DeleteBlankARows() With Application .Calculation = xlCalculationManual . ScreenUpdating = False Dim r As Long For r = Cells(Rows.Count, 11).End(xlUp).Row To 1 Step -1 If Cells(r, 11) = "" Then Rows(r).Delete Next r .Calculation = xlCalculationAutomatic .ScreenUpdating = True End With End Sub
a way to do the reverse viz. for a particular column, I'd like to delete the row corresponding to the non-blank cell in the column.