Delete Rows Outside Date Range

Apr 26, 2006

On sheet2 Range L4:L2000 I have starting dates entered in mm/dd/yy format. On sheet2 Range M4:M2000 I have finish dates entered in mm/dd/yy format.

On sheet3 I have a numeric value of mmddyy (no brackets) in cell BC4.

What i'm looking to do is if the numeric value on sheet3 BC4 does not fall between the start and finish dates on sheet2, then the entire row should be deleted. Can this be done with the different date formats (Brackets vs no brackets)

View 6 Replies


ADVERTISEMENT

Delete Rows If Cell Contains Date Outside Date Range

May 29, 2008

I've found similar queries on the site, but none seem to handle multiple dates, and my attempts so far have been futile!

Requirement:
I press a button on Sheet1 and am prompted to enter a start date and an end date.

Depending on the dates I enter, all rows on Sheet2 which fall outside the Start/End date range will be deleted.

All dates to be checked against on Sheet2 are in a single column, and all rows are populated, there are no blanks. Dates are in the format dd/mm/yy

View 5 Replies View Related

Popup Or Userform Enter Date And Delete Rows Containing That Date

Nov 26, 2013

I wondering if it's possible to create a code to have a popup where the user can enter a date in mm/dd/yyyy format and then all rows containing that date will be deleted.

View 9 Replies View Related

VBA Delete Rows If Date Is Less Than Defined Date

Feb 26, 2014

I have tracker, where Cells in Column F have dates or are blank.

I am trying to run a macro to delete all rows when the following criteria apply:

for all cells in column F, if date < 1-Oct-2013 then entire row should be deleted if cell is blank - nothing should happen This is what I got so far - but it is not working...I have entred the date "10/1/2013" in cell AA2 but macro should always check against that date (not variable) so it might not be needed.

Sub PART3_Delete_old_team_members()
Columns("F:F").Select
Selection.NumberFormat = "m/d/yy;@"
Dim endrow As Integer
On Error Resume Next
endrow = Sheets("Global Team List").Range("F900").End(xlUp).Row
Searchdate = "AA2"

[code]....

View 2 Replies View Related

Delete All Rows Except Most Recent Date

Jan 26, 2009

Have a sheet with 24K rows. Column A is client name. Column B are check dates. The info is sorted by client then check date. Clients can have one to many check dates, so I client is listed as many times as there are check dates. If ten checks, then ten rows for that client. One check then one row for that client.

I only want to keep the last/most recent check date for each client, deleting all other rows for that client with check dates before the most recent. I believe I need to step through the file comparing column A, row by row, to see if I have a match for the next row in A. If no match I keep that row, because there is only one check, and move down one. If a match, then I delete the current row.

How to code this is my problem. Is it a loop?

View 6 Replies View Related

Delete Rows Which Have Date 7 Days Old

Jan 29, 2010

I was wondering if somebody could help me with a little bit of code?

When the sheet is opened, I would like some code to search down column A, starting from cell "A5" and delete all rows which contain a date which is greater than 7 days ago.

The dates are in order from the most recent being at the top.

For example:

Today is 29/01/2010, I would like all rows which have a cell in column A containing Today-7() to be deleted. 28/01/2010 to stay. 19/01/2010, delete row.

Hope that makes sense?

View 6 Replies View Related

Delete Rows Based On Inputted Date

Dec 19, 2006

I need to have a User input a date via an InputBox, and then based upon that date, delete rows based on values in Column G. For instance, if a user inputs 12/25/2006, I need to delete all rows that have the date that is less than 12/25/2006 in Column G. There will never be more than 500 Rows of data, and there is data in Columns A thru Z

View 4 Replies View Related

Compare Dates Against One Date & Delete Rows

Nov 24, 2007

I have a column of dates (B2:B1500) that I want to compare to a single date (A1).

If the dates in Column B are older than the date in A1 I want to delete the entire row.

View 3 Replies View Related

Delete Rows Not Matching Date Variable

Mar 10, 2008

I have a need to call a sheet from another sheet, copy two pages from the newly opened, existing sheet to a new workbook, search one sheet of the new workbook for any entries that don't contain a variable I specify, which is the first four digits of the field, and delete them. The sheets represent a daily view of jobs (identified by the "RptDate" variable) and an entire monthly list of jobs, which I want to delete all of them not from the date specified in the variable "RptDate". The fields in column A contain the date in "mmdd" format as the first four digits, and I have that specified in the "B1" celll of the originating workbook.

I found some code in this link Search Column Delete Row If Value Found that looked good. I had to modify it since I needed to search for a variable (RptDate) and needed to search column A and start on row 8 of that column. My current code looks like this:

Sub Macro1()

Dim RptDate As String
Dim RptMonth As String
Dim iLastRow As Long
Dim i As Long
RptDate = Range("B1").Text
RptMonth = Range("B2").Text
Workbooks.Open Filename:=(RptMonth)
Sheets( Array(RptDate, "Total Database")).Copy
iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = iLastRow To 8 Step -1
If Left(Cells(i, "A").Value, 4) <> RptDate Then
Rows(i).Delete
End If
Next i
End Sub

It works fine right up to the "Rows(i).Delete" line. It errors out with a "run-time error 1004, delete method of range class failed" and highlights the above line. I know the fields I'm pulling the variables from are working right since it opens the correct workbook off of one of them.

View 6 Replies View Related

Delete Rows Based On Date Column

May 10, 2008

modifying the following from deleting rows older than 365 days to delete rows older than 12 months. So I can keep a rolling year by month.

Sub DeleteOldSR()
Dim x As Long
Dim iCol As Integer

Application. ScreenUpdating = False

iCol = 7 'Filter on column G (Create Date)

For x = Cells(Cells.Rows.Count, iCol).End(xlUp).Row To 2 Step -1
s = Cells(x, 3).Value
If s Like "Closed" Or s Like "Closed w/o Customer Confirm" Then
If Cells(x, iCol).Value < (Date - 365) Then
Cells(x, iCol).EntireRow.Delete
End If
End If
Next

Application.ScreenUpdating = True

End Sub

I tried modifying the IF statement using month with the following but it seems to delete all months < and is not year dependant.

If Month(Cells(x, iCol).Value) < Month(Date) - 12 Then

View 6 Replies View Related

How To Delete Range Of Rows

Jan 28, 2013

I need a macro to delete a specific range of rows. For example below:

UK
Manchester
London
Chelsea
Birmingham

[Code]....

Each line represents a row. If a cell matches "JAPAN" then the macro needs to delete all the rows relating to it (in this case all the cities that are based in Japan). So after running the macro my list will have:

UK
Manchester
London
Chelsea
Birmingham

[Code]....

View 2 Replies View Related

VBA Delete Blank Rows Within Range

Jun 23, 2014

I've got a code that generates some worksheets in a fairly large workbook. The code is run monthly and replaces the already existing worksheets.

The problem is that each newly generated worksheets contains more than 1 million rows, which means that the size of each worksheet is around 5MB.

I need a code which allows me to delete all blank rows starting with row 1000 in those worksheets.

View 14 Replies View Related

Delete The Rows Which Have Zero Value In The Named Range

Jun 17, 2009

I have a named range and I want to delete the rows which have zero value in the named range.

View 6 Replies View Related

Macro To Delete Rows Outside Of A Range

Nov 20, 2012

I have a large workseet that I want to Delete all rows where value in column Q is > 9.99 and < 60.00. So the only rows left would be where column Q value is < 9.99 and > 59.99. (deleting out the middle amounts) I think this might be a nested If stmt but have not figured it out so I'm not sure if there is another way.

View 4 Replies View Related

Delete Empty Rows Is Range?

Jan 14, 2014

I am trying to delete all the empty rows in a range. What I currently have deletes the rows but skips over a lot as the code runs. Below is what I currently have.

Code:
'msgbox delete blanks???
If MsgBox("Are you sure you want to delete ALL the blank rows in the chart?", vbYesNo, "Delete Blanks?") = vbNo Then
Exit Sub

[Code].....

View 4 Replies View Related

Delete Empty Rows Within A Set Range

Nov 30, 2006

I have read all the tutorials and examples of how to delete rows IF the row contains no data within a worksheet or workbook.

I don't want all rows deleted, just rows within a set range.
I can't find any reference to deleting blank rows within a range, just the entire workbook or worksheet.

View 9 Replies View Related

Export Data To Sheet And Then Delete Rows NOT Contain Today Date

Jan 25, 2013

I have found some excellent code that exports rows to individual sheets based on values in a column, and it works perfectly. I have found some code that deletes any rows that do not contain today's date:

VB:

Dim LR As Long, i As Long
Application.ScreenUpdating = False
LR = Range("O" & Rows.Count).End(xlUp).Row
For i = LR To 1 Step -1
If Range("N" & i).Value < Date Then Rows(i).Delete 'N is column "Treatment Date"
Next i
Application.ScreenUpdating = True

But I'm having trouble adding this to the code I'm already using (that is working):

VB:

Sub Copy_To_Worksheets_2()
'Note: This macro use the function LastRow and SheetExists
Dim My_Range As Range
Dim FieldNum As Long
Dim CalcMode As Long
Dim ViewMode As Long
Dim ws2 As Worksheet

[Code]...

I tried adding it after the code " ' delete columns (after exporting from Current Patients)" but I received the error "Compile error - Duplicate declaration in current scope" as it relates to Dim LR As Long.

I have attached my spreadsheet : Daily Treatment Summary.xlsm

View 1 Replies View Related

Delete Duplicate Rows Containing The Oldest Date And Time Entries?

May 23, 2014

I have a UserForm which writes data to rows in a master spreadsheet. I'm attempting to write some vba code for a CommandButton in the master spreadsheet which can identify and delete duplicate entries based on "user ID", "Date", and "Time". I would like the CommandButton to retain the most recent entry from a user and delete all previous entries.

My master sheet is set out as such...
A, B, C, D,
UserID, Date, Time, Response

The users could potentially submit multiple entries on the same day. Ideally I would like to be able to click a CommandButton and delete each user's submission but retain their most recent one (based on "UserID", then "Date", then "Time").

I've searched all day for a solution and I've come close but I can not figure out a code that accounts for my three variables ("UserID", then "Date", then "Time").

View 5 Replies View Related

Excel Macro Delete Rows Where Date Criteria Is In Another Sheet

Feb 28, 2014

I am trying to adapt a macro which deletes all rows in Worksheet 1 where the date in column K differs from a date in Worksheet 2. The date in Worksheet 2 will change each day.

I think the macro below could be used, but don't understand how to replace the "Value = ":70:" with a reference to the master date in Worksheet 2.

Sub test() Dim lr As Long, i As Long lr = Range("A1").End(xlDown).Row
For i = lr To 1 Step -1 If Cells(lr, 1).Value = ":70:" Then
Cells(lr, 1).EntireRow.Delete End If lr = lr - 1 Next i End Sub

View 2 Replies View Related

Delete / Hide Rows Meeting User Entered Date

Feb 26, 2008

I would like to setup a macro that brings up a dialog box asking for a date in a specific column. Once that date is entered in the dialog box, the macro would then find all rows before that date (in that specfic column) and delete them.

View 9 Replies View Related

How To Delete Cells In A Range Based On Date

Oct 21, 2013

I have a range (D5:BU5) that I will have various dates in each cell. At the end of the row is a percentage block. It has the formula count=(D5:BU5)/70 which gives me a percentage complete. The fun begins where some dates are based off annual, semi-annual, and quarterly. What I want to do is be able to delete cell values so they are not reflected in the final percentage. I know there is a marco that deletes the entire row but that is too much I just want a target cell.

View 3 Replies View Related

Macro To Delete Rows With A Range For Values

Mar 28, 2009

I need some assistance with a simple macro. Im clueless when it comes to macros.

Heres what I have:

column "e" contains the year built for homes. Some of the fields contain "9999" or "0000" or blank. I need to delete these entire rows. If the year is between 1900 and 2020 I would consider it valid and keep the row.

So I need a macro that says something like this:

if column "e" is not between 1900 and 2020 delete the entire row.

View 11 Replies View Related

Delete Certain Range Of Rows In Single Column?

Jun 10, 2014

I need to delete a certain range of Rows in a single column

View 3 Replies View Related

Macro To Delete Specific Range Of Rows

Jul 12, 2014

I currently had to start from scratch as my formula kept raising the debug screen. I know the answer is simple but I cant figure out what it is. I have column A, rows 9 through 1000 with data. I want to delete the entire row of any "x" value present in column A rows 9 through 1000. I am new to VBA. So simple is good.

View 2 Replies View Related

Delete Rows According To Empty Cell Range

Feb 22, 2007

I am not sure of the VBA code to delete enitre row if a cell is empty only within a range, then Ascend according to that Row's Values and show the
Rank No's only on what Rows that remain.

The end result example is in Sheet2

View 9 Replies View Related

Delete Rows With Values Between Numeric Range

Apr 16, 2008

I want to delete all the rows with values between -1 and 1 in column 'I'. I currently set up a macro to do the formatting and conditional stuff that highlights all values above 1 and below -1 - these are the values I need to conduct my analysis on, but I can't figure out how to delete the rows in between. The worksheet has approximately 5,000 rows (and growing) and this would help me clean up the data significantly.

View 7 Replies View Related

Delete Visible Rows From Filtered Range As Table

Dec 11, 2012

I have a range that has been formatted as a table. Once I've applied a filter, if I try to select all of the rows, and delete the visible rows the option is greyed out.

Is there no way, short of vba, that I can just simply delete the visible rows?

View 1 Replies View Related

Delete Rows With Blank Cells In A Specific Range

Feb 23, 2010

I need a VBA to delete rows with blank cells within columns F - AZ
Columns A - E contain headers but also need to be deleted if cells in columns F -AZ are blank.

View 9 Replies View Related

Add Or Delete Rows From Multiple Sheets Based Table Range

Aug 14, 2009

I have a need to add or delete rows from a number of known sheet names using a table of variables on another sheet that tell me the start row of the sheet I need to go to and the number of rows I need to either add (ie copy rows and paste / insert these) or delete (delete rows).

There are multiple blocks of data I mey need to amend on each sheet and the values in my table of variables will change on each iteration (ie if I delete rows from the first block on a sheet, the start row for the 2nd block I need to amend will need to be updated in the table of variables before I can edit the 2nd block on that sheet).

I have been able to get the process to work for a single instance (ie one sheet and amendments to the first block of that sheet) but I can't figure out how to create the loop to elegantly move to the next set of variables and repeat the process for the 2nd, 3rd, 4th block etc on the first sheet and then move to the 2nd sheet to repeat the process etc.

Public Sub EditCurrentBlock()
Dim rowcount As Integer
Dim startrow As Integer
Dim endrow As Integer
Dim rowcountBal As Integer
'Dim selSheet As Worksheet (tried to use this to nominate the sheet variable but
' had problems so scrapped it)

'Reconfigure the GP Revenue block.................

View 2 Replies View Related

Excel VBA Code To Select A Range (rows) Based On Values And Delete

Aug 8, 2013

I am trying out with a code which checks for cell value as "Select" in column IU and then checks for corresponding column IV for value as "0". Please note that "Select" and "0" are populated by formulas. I need the select "Select" and "0" till the next "Select" occurs in column IU and delete the selected range and continue the process until last non empty cell based on column C.

I have written the below code but it doesn't work.

Code:
Public Sub Test()
Dim nRow As Long
Dim nStart As Long

[Code]....

I could have uploaded the excel file that I am working on but did not find any upload attachment option.

View 1 Replies View Related







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