Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Delete Row when date in activecell doesn't meet the requierments

I have a worksheet containing startdate in Column G and enddate in Column H
per user. I want VBA to test if a user doesn't meet the specifics (from an
inputbox), and then delete the entire row. So basically if user's contracted
has to be activated on or after 1-1-2008 and expired on or before 31-12-2009,
all users that do not meet those specifics get deleted. The date (i.e.
criteria) should be entered through an inputbox.

Thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Delete Row when date in activecell doesn't meet the requierments

If I understand you correctly you want to delete the entire row if the date
in Col.G is greater than 1-1-2008 and Col.H is less than 12-31-2009, right?
This procedure will find the last row in Col.G and scan Col. G and Col.H till
row 2.

Option Explicit

Sub DeleteRows()

Dim lngLastRow As Long
Dim i As Long

lngLastRow = Sheets("Sheet1").Cells(Rows.Count, "G").End(xlUp).Row

For i = lngLastRow To 2 Step -1
If Format(Cells(i, "G"), "m/dd/yyyy") "1/1/2008" Or _
Format(Cells(i, "H"), "m/dd/yyyy") < "12/31/2009" Then
Rows(i).EntireRow.Delete Shift:=xlUp
End If
Next i

End Sub

Hope this helps! If so, let me know and click "YES" below.
--
Cheers,
Ryan


"Basta1980" wrote:

I have a worksheet containing startdate in Column G and enddate in Column H
per user. I want VBA to test if a user doesn't meet the specifics (from an
inputbox), and then delete the entire row. So basically if user's contracted
has to be activated on or after 1-1-2008 and expired on or before 31-12-2009,
all users that do not meet those specifics get deleted. The date (i.e.
criteria) should be entered through an inputbox.

Thanks in advance

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
Delete data in cells that don't meet criteria SITCFanTN New Users to Excel 1 June 10th 06 09:03 PM
Delete rows that do not meet specific criteria SITCFanTN Excel Programming 3 June 6th 06 04:36 PM
Delete rows that don't meet specific criterion SITCFanTN New Users to Excel 5 June 5th 06 12:34 PM
Delete Rows where cells does not meet criteria Danny Excel Worksheet Functions 1 September 12th 05 05:08 PM
how do i delete rows when cells meet certain criteria? Tbal[_4_] Excel Programming 1 August 15th 05 05:19 PM


All times are GMT +1. The time now is 01:57 AM.

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"