Dynamic Macro to copy and paste

ferr

New Member
Joined
Jun 9, 2022
Messages
24
Office Version
  1. 365
Platform
  1. Windows
I have 2 sheets, call it ‘upload’ and ‘final’.
There are calculations that are run behind the scenes I.e. other tabs that require Columns E:AN from the upload tab to be copied and pasted one at a time to the Final tab.
Need a macro, that essentially does this.
  1. Copies E56,E61,E66 from Upload tab and pastes in final tab by looking up the participants in column A and matching to the participants in the upload tab (B56,B61,B66) and the dates in row 1 and matching to the date in row 48 in the upload tab.
For example, E56,E61 and E66 will be pasted in F2,F3 and F4 in the final tab.
  1. The macro will then continue doing this so, it will copy the next 3 in the upload tab E57,E62,E67 and paste in the appropriate cells in the final tab until we get to the last column say AN.
The cells in the upload tab need to be filled up one at a time (3 participants at a time) for the calculations to work, hence why an INDEX MATCH won’t work as the numbers change once pasted.
Also needs to be dynamic, hence why it looks ups the participants and date before pasting as the dates or participants will change.
Thank you.

test macro.xlsx
BCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABB
46Participants
47
48Row Labels11/30/202412/31/202401/31/202502/28/202503/31/202504/30/202505/31/202506/30/202507/31/202508/31/202509/30/202510/31/202511/30/202512/31/202501/31/202602/28/202603/31/202604/30/202605/31/202606/30/202607/31/202608/31/202609/30/202610/31/202611/30/202612/31/202601/31/202702/28/202703/31/202704/30/202705/31/202706/30/202707/31/202708/31/202709/30/202710/31/202711/30/202712/31/202701/31/202802/29/202803/31/202804/30/202805/31/202806/30/202807/31/202808/31/202809/30/202810/31/202811/30/202812/31/2028
49A9,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,8599,859
50B5,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,4445,444
51C6,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,5556,555
52585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585585,858,585########################585,858,585585,858,585
53
54A
55A
56A395,949,4954,696,9696,46446,46446,46446,46446,46446,46446,46446,46446,46446,46446,46446,46446,46446,46446,46446,46446,46446,46446,46446,46446,46446,46446,46446,46446,46446,46446,46446,46446,4644543354536,56546,46446,46446,46446,46446,4645,555433-
57
58
59B
60B
61B4,546,5676,76646,464817,683817,683817,683817,683817,683817,683817,683817,683817,683817,683817,683817,683817,683817,683817,683817,683817,683817,683817,683817,683817,683817,683817,683817,683817,683817,6833,422817,6833,4333,423817,683817,683817,6833,443343817,68334,343,434343--
62
63
64C
65C
66C7,676656,5658,877787878787878787878787878787878783,434,3434,343,4337878787878787878783,43334,343783,43478787878787834343,433-
Upload
Cell Formulas
RangeFormula
B54:B55,B64:B65,B59:B60B54=B55
B56B56=B49
B61B61=B50
B66B66=B51
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E65:AU65Expression=E$45=$E$45+2textNO
E65:AU65Expression=E$45=$E$45+1textNO
E65:AU65Expression=E$45=2025textNO
E55:AU55Expression=E$45=$E$45+2textNO
E55:AU55Expression=E$45=$E$45+1textNO
E55:AU55Expression=E$45=2025textNO
E46:N46,S46:AB46,AG46:AP46,AU46:BB46Cell Value=FALSEtextNO
E46:N46,S46:AB46,AG46:AP46,AU46:BB46Cell Value=TRUEtextNO



test macro.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAO
1ParticipantsJul-24Aug-24Sep-24Oct-24Nov-24Dec-24Jan-25Feb-25Mar-25Apr-25May-25Jun-25Jul-25Aug-25Sep-25Oct-25Nov-25Dec-25Jan-26Feb-26Mar-26Apr-26May-26Jun-26Jul-26Aug-26Sep-26Oct-26Nov-26Dec-26Jan-27Feb-27Mar-27Apr-27May-27Jun-27Jul-27Aug-27Sep-27Oct-27
2A8,787,878.0054,565,465.0067,676.006,676.00
3B6,767,678.0056,655.007,645,435.00754.00
4C34,434,343.00767,667.0054,544.009,548.00
5
6D6,767.004,545.00565,656,564.0076,764.00
7E4,545.006,767.007,676.004,354,544.00
8F----
9
10G8,599.00545,454.00454.004,545.00
11H545.00-94,394.00454.00
12II454.0076.00545,466,565.00-
13
14J4,532.004,545.004,545.00567,786.00
15K----
16L2,324,324.0054,545.0065,656,565.0067,657.00
17
18M----
19N7,676.005,656.00665,656.0056,565.00
20O---56,565.00
21---
22P----
23Q765,434.004,565,656.0056,567.006,565.00
24R----
25----
26S5,555.0022,466,777.00343,456.0075,665,565.00
27T55,567,676.004,554.0067,645,453.0056,565,643.00
28U----
29----
30V5,454.005,653.00-54,453.00
31W554,567.00898,989.0078,708.00434,345.00
32X424.003.0076,545.0056,677,667.00
33----
34Y43,243,435.00545.005,454.0022,323.00
35Z----
36AB15,454.00343.00-232.00
37----
38QC2-354,545.00543,342.00-
39DF4
40DG65.00545,454.0054.00544.00
Final
Cells with Conditional Formatting
CellConditionCell FormatStop If True
O2:AM38Cell Value<0textNO
 
Apologies, rephrased but posted in another thread.
 
Upvote 0

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

On this occasion I have merged both threads.
 
Upvote 0

Forum statistics

Threads
1,223,902
Messages
6,175,278
Members
452,629
Latest member
SahilPolekar

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