Date parameters

  • Thread starter Thread starter Zak
  • Start date Start date
Z

Zak

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.
 
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
 
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.
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top