Deleting Rows With Certain Dates

Apr 18, 2008

I'm trying to create a macro that removes rows that contain dates past todays date.

E.g, in columns A and B are people's names and in column C are start dates. I need to remove any rows of data that contain a date in column C past todays date.

Here is what I have put together so far, but it doesn't seem to work:-

Private Sub CommandButton1_Click()
Dim LastRow As Long
Dim c As Long

LastRow = Range("c65536").End(xlUp).Row
For c = LastRow To 1 Step -1
If Abs(Cells(c, 9)) > Date Then
Cells(c, 9).EntireRow.Delete
End If
Next
End Sub

View 9 Replies


ADVERTISEMENT

Deleting Rows When Dates Exceed Current Date?

Aug 4, 2014

How do I delete rows, with the maturity date exceeding the current date ("A10"). Note here that every time I open the excel sheet, the current date ("A10") would change, so I intend to write a VBA file to ensure that new rows are deleted when the dates expire.

View 8 Replies View Related

Deleting Data Based On Dates Using Macro

Jun 17, 2014

Where is that I have 2 sheets of data, sheet1 contains an ever expanding list of data and I'm trying to create a macro that deletes multiple rows of data from this sheet if the date held within column K is less than the date defined in sheet2.

View 4 Replies View Related

Excel 2010 :: Delete Filtered Rows Without Deleting The Hidden Rows?

Sep 25, 2012

How do I delete filtered rows without deleting the hidden rows in excel 2010?

View 8 Replies View Related

Clear Rows Vs. Deleting Rows To Avoid #REF! Formula Error - Macro

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

Code For Deleting Rows Verses Hiding Rows

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

Delete Blank Rows (formula Not Deleting All Rows)

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

Deleting Rows Macro :: Rows That Don't Contain Word ...

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

Deleting Rows/content Of Rows

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

VBA And Deleting Rows

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

Deleting Rows That Contain Particular Value

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

Deleting Rows

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

Deleting The All Rows

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

Deleting Specific Rows..

Feb 21, 2009

Here's my problem. I have the following table:

View 5 Replies View Related

Deleting Multiple Rows?

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

Deleting Rows Based On Their Value

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

Deleting Specific Rows ....

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

Deleting Rows With Macro

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

Loop For Deleting Rows

Apr 20, 2009

Loop for Deleting Rows
Whats wrong with my code ?

View 3 Replies View Related

Deleting Rows On Conditions

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

Deleting Unwanted Rows <10

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

Deleting Duplicate Rows

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

Deleting Rows If A Condition Is Met?

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

Deleting 4 Rows Because Of 1 Item?

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

Deleting Rows Using A Macro

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

Deleting Multiple Rows?

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

VBA Deleting Rows Just Copied

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

Deleting Rows In Filtered Set With For Each?

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

Deleting Rows From Table Using VBA

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

Deleting Rows That Contain Certain Text

Aug 1, 2014

I have a sheet where individual actions are listed and then subtotaled.

ElementError Code
Action NAC-01
Action NAC-02
Action NAC-07
Action NAC-08
Action NAC-14

[Code] .......

I need to remove all the subtotal rows.

View 2 Replies View Related







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