VBA - Copy Paste in last workday

joslaz

Board Regular
Joined
May 24, 2018
Messages
76
Hello everybody!


I'm currently facing a relatively simple problem.
I have the following table:
There are values in the Range B2:F2
Then there are a calender column since A5 - like below

ABCDEF
100150207050
01.01.2019
02.01.2019
03.01.2019
04.01.2019
05.01.2019

<tbody>
</tbody>


Now I just want to copy the values from B2:F2 in the respective row (Bx:Fx) with the date of yesteray - but just for a workday.
When today is mondey it should copy the values in friday.


Does anyone how to manage that?

Best Regards
 
Last edited:

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Code:
Dim d As Range: Set d = [A:A].Find(CDate([WORKDAY(TODAY(),-1)]))
If Not d Is Nothing Then [B2:F2].Copy d(1, 2)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,885
Messages
6,122,090
Members
449,065
Latest member
Danger_SF

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top