Deleting Rows On Condition
Nov 2, 2007
I need macro to perform the following steps. I have also enclosed the image of the file for reference.
1)I need to move or copy the data in sheet one to sheet two.
2) In sheet two I need to select customer BBBB and delete all the rows beginning with PO# of 17, 18, 46 or GL4.
3) finally I want to delete all the rows in the sheet which are not equal to class Invoice. (Presently I do this using custom filter as "doesnot equal" = Invoice") ..
View 11 Replies
ADVERTISEMENT
Jan 18, 2012
I have data in the format below. I'm looking for a piece of code that will look down column B and if there are 30 rows in which all the values are zero then delete all rows from row 1 to the last row of those 30 rows.
Input_data AB106/01/2012 13:03:170206/01/2012 13:03:1816306/01/2012 13:03:1916406/01/2012 13:03:2016506/01/2012 13:03:2117606/01/2012 13:03:2224706/01/2012 13:03:2316806/01/2012 13:03:240906/01/2012 13:03:259.51006/01/2012 13:03:26191106/01/2012 13:03:27211206/01/2012 13:03:28161306/01/2012 13:03:2981406/01/2012 13:03:3001506/01/2012 13:03:31571606/01/2012 13:03:32801706/01/2012 13:03:331091806/01/2012 13:03:341331906/01/2012 13:03:35156
View 1 Replies
View Related
Aug 8, 2012
I have a data dump. I download everyday with 200 rows and 20 columns. I need to remove any rows where there is no value in either columns C or D. Is there a quick way to do this?
View 7 Replies
View Related
Feb 29, 2008
I have a list of data (this list is variable) and I want to delete the rows that have the word Revaluation in column L.
I tried the following but it did not work
Sub Delete()
Dim Lastrow As Long, i As Long
Lastrow = Cells(Rows.Count, "L").End(xlUp).Row
For i = Lastrow To 1 Step -1
If Range("L" & i).Value = Revaluation Then Rows(i).EntireRow.Delete
Next i
End Sub
View 9 Replies
View Related
Sep 25, 2012
How do I delete filtered rows without deleting the hidden rows in excel 2010?
View 8 Replies
View Related
Jun 9, 2009
I have a macro which is copying data from several worksheets into one consolidation worksheet. When determining where to paste the data into the consolidation sheet, the macro includes some logic to find the last row that has data in it (using e.Range("A65536").End(xlUp).Row, where "e" is a variable holding the name of the consolidation worksheet).
Once all the data is on the consolidation worksheet, I have a second worksheet with formulas that link to the consolidation sheet. The issue I have is that the first step of my consolidation macro deletes all data on the consolidation sheet to ensure that no data is double-counted). I am deleting the data with logic that simply deletes all rows from 3 to 65536. Once these rows are deleted, Excel returns a #REF! error on my second worksheet which is linking back to this data.
Rather than deleting the rows on the consolidation sheet, I have tried using the Clear and/or ClearContents commands instead. This works (i.e., my formulas no longer error out), but results in the consolidation macro running very slowly (~15 minutes, compared to
View 9 Replies
View Related
May 25, 2013
The first code hides everything just fine based on the date in A1. When I change it to the second code to delete instead of hide it is leaving a bunch of rows that the 1st code hides. Both codes have the same search criteria.
Code:
For Each cell In Range("B8:B5000") If cell.Value Range("A1").Value Then cell.EntireRow.Hidden = True
Next cell
Code:
For Each cell In Range("B8:B5000") If cell.Value Range("A1").Value Then cell.EntireRow.Delete
Next cell
View 4 Replies
View Related
Sep 30, 2008
I have the following codes to delete all blank rows in column A
Dim lastrow As Long
lastrow = Sheet1.Range("A" & Rows.Count).End(xlUp).Row
MsgBox lastrow
With Sheet1
For t = 1 To lastrow
If Cells(t, 1) = "" Then
Rows(t).Delete
End If
Next t
End With
End Sub
Although it is working , it is not deleting all the blank rows at once, I have to keep pressing on the macro button running the macro several times, until all blank rows are completely deleted.
View 9 Replies
View Related
Jan 9, 2008
I got a code to delete all rows in the sheet which contain the word "DETAILS" but I now want to delete all the rows that do not contain the word "DETAILS"
My code if needed is:
Sub Find_details()
Dim rng As Range
Dim what As String
what = "DETAILS"
Do
Set rng = ActiveSheet.UsedRange.Find(what)
If rng Is Nothing Then
Exit Do
Else
Rows(rng.Row).Delete
End If
Loop
End Sub
View 9 Replies
View Related
Jun 21, 2008
I have an imported report in a spreadsheet. It imports to three columns. I need to check each row in column A for three seperate criteria and delete the rows I don't need. I need to delete blank rows and check next row for page header info. Delete these and next rows to next blank cell. Check next row for page header and not delete if not page header. Several rows down will be a cell with 23 blank spaces before the word Reg: and sometimes other words past this but always this first. This row is to be kept. I looked at the FAQ's example of Deleting but I don't think it will work. I also need to put a key word in column A at a point where I want to stop. This report is a couple thousand rows long so a VBA procedure would really save time. I have a procedure I use to check for two zero's in two cells that hide these rows but I couldn't modify it to work on this report.
View 9 Replies
View Related
Dec 11, 2009
Say I have a method that iterates through a bunch of Sheets. I check the name of every sheet, if it starts with "Data", I need to make everything between A4 and AZ500 empty (either by clearing cells or deleting rows doesn't matter how, as long as the result is an empty sheet below A4).
View 2 Replies
View Related
Sep 21, 2009
I have an excel spreadsheet that contains about 1000 rows and about 25 columns. The file contains employee information, name, id, cost center, department, title, FTE...etc. Column E contains the cost center which is a 7 digit number (i.e. 8001234). Within the 1000 rows of data there somewhere to 70 cost centers. I would like to delete all rows where a cost center does not match a list of 13 cost centers. I'm thinking I need some kind of array where I type in the 13 cost centers in the code, but I'm unsure of the syntax within VBA.
Also, the second step of the code I'm looking for is to delete all columns except for Column B, E, J and L. Those, by the way are Name, Cost Center, Job Title and FTE.
View 2 Replies
View Related
Oct 26, 2011
I want to delete all rows in the column of the ActiveCell when the ActiveCell.value < 0.01. Could you tell me why the code below doesn't work? It deletes the right rows but keeps looping without stopping
Sub DeleteZeros()
Dim Col As Long
Dim StopRow As Long
Col = ActiveCell.Column
StopRow = Cells(Rows.Count, Col).End(xlUp).Row
Range("A1").Select
[Code] .........
View 6 Replies
View Related
Apr 25, 2007
I have a macro that deletes rows. For some reason, the macro bombs out when the selection seems to be too big. Why is that?
deleterow_min = Sheets("Sheet1").Cells(1, 6)
deleterow_max = Sheets("Sheet1").Cells(1, 7)
Rows(deleterow_min & ":" & deleterow_max).Select
Selection.Delete Shift:=xlUp
View 9 Replies
View Related
Aug 5, 2009
In a part of my code I have something that will delete all hidden rows, like:
For Z = 1 To TotalRows - 1
If Cells(TotalRows - Z, 1).EntireRow.Hidden Then
Cells(TotalRows - Z, 1).EntireRow.Delete
End If
Next Z
I've done it in reverse to be quicker, but it's still quite slow. Granted, I am deleting several thousand rows, but surely there's a quicker way? Thinking about it logically I would presume that (in general) selecting stuff first in Excel and then deleting them appears to be quicker, but I'm not sure how to pull that off.
View 9 Replies
View Related
Feb 21, 2009
Here's my problem. I have the following table:
View 5 Replies
View Related
Mar 15, 2013
I have a large list of coordinates that I pasted from a website, and in Excel it has an emty row between every coordinate. I have about 2,000 cordinates, so ~4,000 rows. Is there a way to delete every other row besides manually?
View 1 Replies
View Related
Jun 26, 2008
I am having trouble with the .SpecialCells(xlCellTypeBlanks)
What I need to do is for a macro to first go through a range ("G8:G50"), Add a 0 value to any blank cell.
Then I want the macro to delete the entire row for any of the cells that have a value of 0 in that range of "G8:G50"
View 9 Replies
View Related
Nov 9, 2008
I have created a worksheet (through an import into MS Excel 2007) which contains 287,281 rows. However, the data I need is located in rows: 4, 67, 130, ... (or n+63) rows.
View 10 Replies
View Related
Mar 19, 2009
I want to delete every second row, because I have data with 0.25m interval and I want 0.5m interval. Why I try the following it doesn't work?
View 2 Replies
View Related
Apr 20, 2009
Loop for Deleting Rows
Whats wrong with my code ?
View 3 Replies
View Related
Apr 24, 2009
I would like to delete rows that are based on these conditions: First ,Do a loop from row 2 to last available row. - Delete rows with same column(column B) that has the same value. However I want the last available row with the same ID to remain.
- Delete Rows with any values in found in other sheet column B. When the value taken from the first sheet(ABC) is compared to the column B in second sheet(DEF), if they are equal, the row will be deleted in the second sheet and the rows in first sheet will main. I had attached an simple example with the 2 sheets. The Result are shown in the example.
View 2 Replies
View Related
Aug 24, 2009
I need some VBA to delete rows that are under the value of 10 in column H and keep the rest, is there a way of doing this
View 7 Replies
View Related
Oct 14, 2009
In my Excel 2003 worksheet I need a macro to search column B for duplicate entries. The data in column B is both numeric and string. If there are any duplicate entries, then I need the duplicate rows to be deleted.
View 4 Replies
View Related
Feb 8, 2012
way to delete multiple rows in a large spreadsheet with automation Example:
84076 Cantor 10 Retail Tue Nov 08, 2011 160 REVISED Division 8 1600 Compulsion Done 84077 Cantor 10 Retail Thu Nov 17, 2011 160 CANCELLED Division 8 1600 Compulsion Done 84078 Cantor 10 Retail Thu Oct 13, 2011 88 Division 8 880 Compulsion Done
I would need to delete all 4 rows within the "Cancelled" Box, but in a spreadsheet of 12000 boxes of 4. so, probably a macro to find them all, and delete them would be the way to go.
View 2 Replies
View Related
Jul 25, 2012
I'm looking for a macro that will delete a row with a certain value (0.00) and the row below it.
View 9 Replies
View Related
Jan 18, 2013
In my spreadsheet, column A can contain the same word over several rows. If column B is blank at any time - I want to delete all rows that have the same word in column A.
Apple 1
Orange 2
Apple
Peach 1
Peach 2
So in this example - I want to delete rows 1 and 3 that show the word Apple.
View 2 Replies
View Related
Feb 1, 2013
I have this bit of code which is working perfectly. Now I need it to delete the rows it just copied. How would I go about doing this?
Sub TESTMonthEndReport()
Dim x As Long, y As Long
y = 2
Application.ScreenUpdating = False
For x = 1 To Worksheets("January 2013").Range("K276").End(xlUp).Row
If Worksheets("January 2013").Range("K" & x) = "Waiting" Then
Worksheets("January 2013").Range("K" & x).EntireRow.Copy
Sheets("February 2013").Range("A" & y).PasteSpecial
Application.CutCopyMode = False
y = y + 1
End If
Next x
End Sub
View 2 Replies
View Related
Apr 8, 2013
I am working on solving a problem where I get every other row deleted instead of every row. The situation is that I am using Autofilter to find empty cells in a column that shouldn't have empty cells. Before I can delete them, I need to add them to an array for exceptions handling. This means I need to step through the filtered range and record each unique ID for followup, then delete them. If I delete as I go, the "For Each" doesn't work on the original rows, but works on an increment. This means a deleted row causes the range to shift up one, and I end up deleting every other row.
I know I can solve this by deleting separately from recording them, but am searching for a way to work with the "For Each" maybe using a "Step -1" or something similar.
View 9 Replies
View Related
May 29, 2014
I would like to delete a given row from a table using VBA
If I use the following Code it works
[DeleteTest].Select
Selection.ListObject.ListRows (120).Delete
Is there anyway to run this where the 120 is inserted dynamically. I tried the following but it does not work. Test Delete Row is a named range. It does insert the correct row number, but still does not execute
Dim DelRow As String
DelRow = [TestDeleteRow]
[DeleteTest].Select
Selection.ListObject.ListRows(DelRow).Delete
View 6 Replies
View Related