PC Review


Reply
Thread Tools Rate Thread

Delete Row when date in activecell doesn't meet the requierments

 
 
Basta1980
Guest
Posts: n/a
 
      6th Oct 2008
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 With Quote
 
 
 
 
RyanH
Guest
Posts: n/a
 
      6th Oct 2008
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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
ActiveCell offset delete Woodi2 Microsoft Excel Programming 5 14th Mar 2009 08:08 PM
Re: Delete Activecell if it is not numeric Dave Peterson Microsoft Excel Programming 0 11th Apr 2008 02:35 PM
Delete first character in ActiveCell Andy Microsoft Excel Programming 9 5th Sep 2005 12:00 AM
VB TAB doesn't move activecell?? Ben W Microsoft Excel Programming 2 17th Jan 2005 03:27 PM
game requierments Drew Windows XP Hardware 0 30th Aug 2003 06:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:06 PM.