PC Review


Reply
Thread Tools Rate Thread

Date parameters

 
 
Zak
Guest
Posts: n/a
 
      19th Feb 2008
How do i set a date code in macro to tell it to select dates in column A from
only the last 5 working days, including the current day, in sheet called "1".

thanks.
 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      19th Feb 2008
With Sheets(1)
RowCount = 1
Do While .Range("A" & RowCount) <> ""
StartDate = .Range("A" & RowCount)
EndDate = Date
wrkdays = DateDiff("d", StartDate, EndDate) - _
(DateDiff("w", StartDate, EndDate, vbSaturday) + _
DateDiff("w", StartDate, EndDate, vbSunday)) + 1
If wrkdays <= 5 Then

End If
RowCount = RowCount + 1
Loop
End With

"Zak" wrote:

> How do i set a date code in macro to tell it to select dates in column A from
> only the last 5 working days, including the current day, in sheet called "1".
>
> thanks.

 
Reply With Quote
 
Zak
Guest
Posts: n/a
 
      19th Feb 2008
Hi,

I tried it but it just highlights the lines and doesnt do anything:

wrkdays = DateDiff("d", StartDate, EndDate) - _
(DateDiff("w", StartDate, EndDate, vbSaturday) + _
DateDiff("w", StartDate, EndDate, vbSunday)) + 1

You mention sat and sun is this to exclude them (just trying to understand
code)?

Also, are you able to put the code as a whole macro? i get confused trying
to do a beginning and an end.

sorry! appreciate your help.

"Joel" wrote:

> With Sheets(1)
> RowCount = 1
> Do While .Range("A" & RowCount) <> ""
> StartDate = .Range("A" & RowCount)
> EndDate = Date
> wrkdays = DateDiff("d", StartDate, EndDate) - _
> (DateDiff("w", StartDate, EndDate, vbSaturday) + _
> DateDiff("w", StartDate, EndDate, vbSunday)) + 1
> If wrkdays <= 5 Then
>
> End If
> RowCount = RowCount + 1
> Loop
> End With
>
> "Zak" wrote:
>
> > How do i set a date code in macro to tell it to select dates in column A from
> > only the last 5 working days, including the current day, in sheet called "1".
> >
> > thanks.

 
Reply With Quote
 
Zak
Guest
Posts: n/a
 
      19th Feb 2008
Sorry forgot to mention, once it has filtered for the dates within the last 5
days it should copy only columns A,C,F,G,U,Z to sheet "2" within the same
workbook.


thanks.

"Zak" wrote:

> Hi,
>
> I tried it but it just highlights the lines and doesnt do anything:
>
> wrkdays = DateDiff("d", StartDate, EndDate) - _
> (DateDiff("w", StartDate, EndDate, vbSaturday) + _
> DateDiff("w", StartDate, EndDate, vbSunday)) + 1
>
> You mention sat and sun is this to exclude them (just trying to understand
> code)?
>
> Also, are you able to put the code as a whole macro? i get confused trying
> to do a beginning and an end.
>
> sorry! appreciate your help.
>
> "Joel" wrote:
>
> > With Sheets(1)
> > RowCount = 1
> > Do While .Range("A" & RowCount) <> ""
> > StartDate = .Range("A" & RowCount)
> > EndDate = Date
> > wrkdays = DateDiff("d", StartDate, EndDate) - _
> > (DateDiff("w", StartDate, EndDate, vbSaturday) + _
> > DateDiff("w", StartDate, EndDate, vbSunday)) + 1
> > If wrkdays <= 5 Then
> >
> > End If
> > RowCount = RowCount + 1
> > Loop
> > End With
> >
> > "Zak" wrote:
> >
> > > How do i set a date code in macro to tell it to select dates in column A from
> > > only the last 5 working days, including the current day, in sheet called "1".
> > >
> > > thanks.

 
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
Using Date Parameters in a Query with Date and Time Alaska1 Microsoft Access 7 19th May 2010 11:49 PM
Date Parameters jlo Microsoft Access Reports 6 25th Jun 2008 01:01 PM
Date Parameters =?Utf-8?B?QnJhbmRlbg==?= Microsoft Access Forms 3 20th May 2005 02:47 AM
Date Parameters Chuck Microsoft Access Reports 1 14th May 2004 10:38 PM
date parameters JohnB Microsoft Access Reports 1 5th Jan 2004 01:59 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:23 PM.