|
-
May 31st, 2013, 05:44 PM
#1
Thread Starter
New Member
Delete Rows with dates older than previous Friday
Hello,
I'm fairly new to VBA and currently automating a weekly report.
I extract this report from a sheet within a workbook managed by another department, then clean it up to be used as a source file for a larger report. Normally, I run this report on Fridays, but occasionally I'll do it over the weekend or Monday. All rows with a date (column H) older than the previous Friday must be deleted. For example, today is Friday, 5/31/13 so I need to delete all rows with a date greater than Friday, 5/24/13.
Although I know code that will delete rows exactly 7 days back, but I don't know how to create code that will use a date range and will pass this on to someone in an admin role after finishing the automation. Attached is a sample of the report.
Thank you in advance for any who take the time to help me. 
DELETE ROWS BY DATE.txt
-
Jun 3rd, 2013, 07:02 AM
#2
Re: Delete Rows with dates older than previous Friday
Although I know code that will delete rows exactly 7 days back
i think if you use
7 + weekday(now,vbFriday) -1
should delete all from the friday previous
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|