Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove non-business days between dates dgold82 Excel Discussion (Misc queries) 4 June 29th 09 04:00 PM
Format time column to remove dates rory_r[_2_] Excel Discussion (Misc queries) 4 January 23rd 09 03:48 PM
remove rows in one sheet from similar rows in another G[_2_] Excel Worksheet Functions 0 November 12th 07 03:57 PM
remove dates is the middle of a line jason2444 Excel Discussion (Misc queries) 2 June 20th 07 03:55 AM
remove dates from chart Rebecca Charts and Charting in Excel 2 May 2nd 07 04:08 PM


All times are GMT +1. The time now is 03:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"