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


ADVERTISEMENT

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

For Loop And Delete Entire Column

Oct 1, 2012

I have two worksheet. One worksheet (ws1) contains a list of item I want. The other sheet (ws2) contains multiple columns where the header (row 6) is named by item name.

I have the following code which deletes the entire column if the header name is not in the list contained in ws1 :

VB:
Sub delete_col()
Dim wanted As Boolean
Set ws1 = Workbooks("test1").Sheets("aaa")

[Code]....

First of all, this loop does not work properly since deleting the entire column shift them on the left, so when I first analyze column 11, if I delete it and then analyze column 12, the real column 12 now became column 11 and so on...

Secondly, this code is pretty slow. I am pretty sure I don't have to loop through my initial item list everytime I do Instr on a new column.

View 9 Replies View Related

How To Delete Entire Column If It Is Empty

Feb 21, 2013

I have columns

Row 1 is heading..

IF Column C doesn't have data in entire column then delete C D E F
IF Column D doesn't have data in entire column then delete D E F
IF Column E doesn't have data in entire column then delete E F
IF Column F doesn't have data in entire column then delete F

Same way for heading NN's

IF Column G doesn't have data in entire column then delete G H I J K L M N
IF Column H doesn't have data in entire column then delete H I J K L M N
IF Column I doesn't have data in entire column then delete I J K L M N
IF Column J doesn't have data in entire column then delete J K L M N
IF Column K doesn't have data in entire column then delete K L M N
IF Column L doesn't have data in entire column then delete L M N
IF Column M doesn't have data in entire column then delete M N
IF Column N doesn't have data in entire column then delete N

View 1 Replies View Related

Delete Entire Row If Column D Has A Numeric Value?

Apr 15, 2014

i want to delete entire row if D2:D10000 has a numeric value e.g .111 to 100000.1114

View 4 Replies View Related

Delete Entire Row If Column C Is Blank?

Apr 16, 2014

i want to delete entire row if Column C2:C1000 are blank

e.g if range c2:c100 have data then delete the rows C101:C1000

View 3 Replies View Related

If Column B Is Blank Delete Entire Row

Jul 23, 2007

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
Else
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
ActiveSheet.Rows(r).EntireRow.Delete
End If
Next r

EndMacro:

View 9 Replies View Related

How To Delete Entire Row Based On Criteria On A Column

Oct 19, 2011

Simple code that can delete entire row if certain criteria is met in a single cell

Example

I have a bank statement where under a first column (DATA TYPE), the cell could contain either "DATA" or "TOTAL"

How can I delete the rows contain the word "TOTAL" assuming the column is already sorted.

View 3 Replies View Related

If Cells In Column L Is Less Than Or Equal To 2:00 (H:MM) Than Delete Entire Row

Dec 3, 2012

I need automatically deleting of whole row based on cell value, if value of cell which is in h:mm format, is less than or equal to 2:00 (h:mm)

So far I got.

Code:
Sub FillDownFormula()

Code:
Range("L2").Formula = "=RC[-3]-RC[-2]"
Range("L3").Select
Columns("l:l").Select
Selection.NumberFormat = "h:mm"
Dim rng As Range

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

View 2 Replies View Related

If Column A Is Blank Delete Data From Entire Row?

Mar 20, 2014

Is there a way to delete any text or formula from an entire row, based on column A? In my spread sheet I have multiple rows where column A is blank, but column's F, G, and H have formulas in them. I would like to use VB or any other method that would be best to clear the contents of all the rows where column A is blank.

View 6 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

Delete Entire Row If Column A Matches Column D

Aug 18, 2009

Does anyone have a macro that will delete entire row if column a matches column d

View 6 Replies View Related

Delete Entire Column If Word False Exists?

Apr 9, 2014

I have the following code, but it takes longer than expected to run. Is there anyway to speed this up? I am not sure if autofilter is a option. I just want to search through range A16:Z16 and if the word "FALSE" exists delete the entire column. The word "TRUE" is the only other word that would exist in range A16:Z16

[Code]....

View 6 Replies View Related

Search Column A For Blank Cells And Delete Entire Row

May 20, 2009

I have tried several methods to delete the entire row if the cell in column 'A' is blank ...

View 9 Replies View Related

Macro To Delete Entire Row If First 2 Letters In Column B Equals To P4

Mar 29, 2013

I've seen a few examples of macros to delete the row if the first letter is something, but not if the first 2 is equal to something.

I'm looking to go thru every row that contains data and look in Column B to see if it starts with P4 or P5. If that's true, then delete the entire row.

View 8 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

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

Macro To Delete An Entire Row If A Duplicate Entry Appears Only In A Certain Column.

Feb 20, 2009

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

Delete Entire Rows Where 1 Column Meets Multiple Criteria

Sep 17, 2007

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

Select Column C And Delete Blank Entire Rows Till C300

May 4, 2014

i want to delete entire blank row from column C2:C300 i mean if i have data c2:c100 then c101:c300 delete entire blank rows

View 4 Replies View Related

Excel 2010 :: Find String And Delete Column On All Worksheets

Jul 9, 2014

Why my code is not working. I am working with Excel 2010. It will only delete the column on the active spreadsheet and not go to next worksheet. Not all worksheets contain the word "Broker".

[Code] ......

Not sure if its something to do with Activecell, try After:=ws.cells(1,1) or passing it in as the active cell stays the same i think.

View 3 Replies View Related

Delete Rows If Column Has Fewer Than X Matches To Part String Match

May 5, 2008

I have data sets on multiple worksheets within a workbook (over 70). Based on the begining of a string, I need to count all instances with that begining, and if there are fewer than 12 instances, delete the entire row.

Data set example:

In this example, I need to count each instance of rows starting with 1/* - 9/*, and delete rows as mentioned. In other data sets the string might start Gi1/*, and so on. In the following code, if I do not loop, and only test against 1 value type, and ONLY run it once, it works. As soone as I try to loop through all possibilities, or run the macro a second time, it blanks out the entire worksheet, starting at row 3.

Dim c As Long
c = Worksheets(i).Range("A" & Rows.Count).End(xlUp).Row
With Range("A3:A" & c)
If Application.WorksheetFunction.CountIf(Worksheets(i).Columns(1), "1/*") < 12 Then
. AutoFilter field:=1, Criteria1:="1/*"
.Offset(1).Resize(.Rows.Count - 1, 1).EntireRow.Delete
.AutoFilter

I have also tried to concatenate a variable with my CountIf criteria, but that fails miserably.

View 6 Replies View Related

Delete Entire Rows Where Column IV Contains "x"

Aug 19, 2008

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"
.Offset(1).EntireRow.Delete
.AutoFilter
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 9 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







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