Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Remove rows with dates
I tried this macro and it doesn't seem to do anything .. .I found it below.
I was hoping it would delete row with certain dates in a spreadsheet. Is there something missing in the code? Sub test1() Dim c As Excel.Range x = InputBox("start date?") y = InputBox("stop date?") For Each c In Selection If c < x And c y Then cell.EntireRow.delete End If Next End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Remove rows with dates
Looks broken to me...
If you want the code to delete dates in the Selection which are outside the date window specified, then change the following: from: If c < x And c y Then to: If c < x Or c y Then If you want the code to delete dates in the Selection which are inside the date window specified, then change the following: from: If c < x And c y Then to: If c = x And c <= y Then Just beware of the < <= = because they can cause pain with dates (especially date windows) if you don't get the rules for them correct up front - they can be very different depending on purpose. -- Rob van Gelder - http://www.vangelder.co.nz/excel "ExcelBeginner" wrote in message ... I tried this macro and it doesn't seem to do anything .. .I found it below. I was hoping it would delete row with certain dates in a spreadsheet. Is there something missing in the code? Sub test1() Dim c As Excel.Range x = InputBox("start date?") y = InputBox("stop date?") For Each c In Selection If c < x And c y Then cell.EntireRow.delete End If Next End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Remove non-business days between dates | Excel Discussion (Misc queries) | |||
Format time column to remove dates | Excel Discussion (Misc queries) | |||
remove rows in one sheet from similar rows in another | Excel Worksheet Functions | |||
remove dates is the middle of a line | Excel Discussion (Misc queries) | |||
remove dates from chart | Charts and Charting in Excel |