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

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
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,213,546
Messages
6,114,251
Members
448,556
Latest member
peterhess2002

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