• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to exclude Saturday and Sunday

Shailender

Member
Hello, all I have a query, as I am working on dates, question here is I want to copy the yesterday's data from other workbook with the help of dates, challenge comes when Saturday and Sunday comes. When I start copying on Monday it is going to Sunday, wherein i want to copy Friday the data, how could i should do with the help of macro. I have highlighted the dates in the sample sheet with yellow color.

Appreciate your help! Thank you.
 

Attachments

  • Dates2.xlsx
    9.1 KB · Views: 1
@Chihiro Here is the sample excel sheet which you requested. I didn't written the code. And here is the detailed description.

Let's say today is Monday, this is the data I have in other workbook(Please refer to the Sheet1 i have highlighted the data in red color and dates in yellow color), here I want macro to do is it should go to that workbook and copy Friday's data and should paste in this workbook since Saturday and Sunday is a holiday. Likewise it should do the same thing whenever we get Saturday,Sunday. And in working days(Monday to Friday) if the yesterday's cell is empty(Due to some holiday) it should take day before yesterday's data and should paste in this sheet.

Thank you in advance!
 

Attachments

  • Dates2.xlsx
    10.4 KB · Views: 1
So the source workbook has exactly the same data structure as your output?

If not, I need source workbook sample as well.
 
@Chihiro, i have attached the sheet please refer to Sheet2. This is the data i have in the other source data.

Thank you in advance!
 

Attachments

  • Dates2.xlsx
    11.1 KB · Views: 1
Try attached.

Since your source workbook has data in alignment each row. You can just use ADO to bring in info as is.

Code in TestADO.xlsb use button to bring in data from Source.xlsb

Place both in same folder. Or change sFile string in code.
 

Attachments

  • Source.xlsb
    8 KB · Views: 3
  • Test.xlsb
    18.7 KB · Views: 5
Back
Top