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").
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...........
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.
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
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
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.
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
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.
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)
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.
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
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...
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.
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.
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.
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.
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.
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?
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
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.