Hi experts,
I need macro to populated data from the last sheet contains data for columns A,B and the last column(last column will be change in location dynamically in every sheet ) to next sheet in column A,B,C. the column C = last column from last sheet . the next sheet should add by macro based on current month , the sheet name should be STOCK_ & current month
example : STOCK_FEB, STOCK_MAR ...... , but if I have current month every time when run the macro should not repeat adding the same sheet for the same month just replace data for the sheet has already added for the month is relating of it
so in STOCK sheet should copy data from columns A,B and the last column will be column(H) to STOCK_JAN sheet based on current month , if the current month is not JAN then will not add STOCK_JAN sheet and copy data from STOCK sheet, but if the current month is JAN then will add STOCK_JAN sheet and copy data from STOCK sheet . and if every time run the macro and the current month is JAN as example then just replace data without repeat adding sheet for the month like STOCK_JAN(1).
. after copy to STOCK_JAN sheet will copy data from STOCK_JAN sheet to STOCK_FEB sheet with the same condition and so on for every current month ,
result in STOCK_JAN if the current month is JAN sheet when run the macro
[
and if fill others columns in STOCK_JAN sheet will copy to next sheet STOCK_FEB if the current month is FEB like this
the result in STOCK_FEB sheet when run macro again like this
and if the current month is MAR then will copy from STOCK_FEB sheet and add MAR sheet like this
I hope finding solution from experts soon
thanks.
I need macro to populated data from the last sheet contains data for columns A,B and the last column(last column will be change in location dynamically in every sheet ) to next sheet in column A,B,C. the column C = last column from last sheet . the next sheet should add by macro based on current month , the sheet name should be STOCK_ & current month
example : STOCK_FEB, STOCK_MAR ...... , but if I have current month every time when run the macro should not repeat adding the same sheet for the same month just replace data for the sheet has already added for the month is relating of it
so in STOCK sheet should copy data from columns A,B and the last column will be column(H) to STOCK_JAN sheet based on current month , if the current month is not JAN then will not add STOCK_JAN sheet and copy data from STOCK sheet, but if the current month is JAN then will add STOCK_JAN sheet and copy data from STOCK sheet . and if every time run the macro and the current month is JAN as example then just replace data without repeat adding sheet for the month like STOCK_JAN(1).
. after copy to STOCK_JAN sheet will copy data from STOCK_JAN sheet to STOCK_FEB sheet with the same condition and so on for every current month ,
TT.xlsm | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | |||
1 | S.N | ITEM | QTY | 01/12/2023 | 02/12/2023 | 03/12/2023 | 04/12/2023 | 05/12/2023 | ||
2 | 1 | CTR 12-200M45 MM 123H K/L | 12.00 | 10.00 | 12.00 | 10.00 | 22.00 | |||
3 | 2 | CCTR 12-200M45 MM 123H K/L | 13.00 | 11.00 | 13.00 | 20.00 | 23.00 | |||
4 | 3 | TR 200M45MM LK H K/L | 14.00 | 12.00 | 14.00 | 30.00 | 24.00 | |||
5 | 4 | TR 200M451 NMM LK H K/L | 15.00 | 13.00 | 15.00 | 40.00 | 25.00 | |||
6 | 5 | TTR 12200S45 MN 123 | 16.00 | 14.00 | 16.00 | 50.00 | 26.00 | |||
7 | 6 | TR 1425/148V MN 123H K/L | 17.00 | 15.00 | 17.00 | 60.00 | 27.00 | |||
8 | 7 | TR 200M45 MM 123H K/L SS | 18.00 | 16.00 | 18.00 | 70.00 | 28.00 | |||
9 | 8 | TR 2.5M100* 123H K/L | 19.00 | 17.00 | 19.00 | 80.00 | 29.00 | |||
10 | 9 | TR 2.5M100**123H K/L | 20.00 | 18.00 | 20.00 | 90.00 | 30.00 | |||
11 | 10 | TRMN 22.5M100* 123H K/L | 21.00 | 19.00 | 21.00 | 100.00 | 31.00 | |||
12 | 11 | TTRM 12200S45 MN 1234 | 22.00 | 20.00 | 22.00 | 110.00 | 32.00 | |||
13 | 12 | TTRR 1200S45 MN 123 | 23.00 | 21.00 | 23.00 | 120.00 | 33.00 | |||
14 | 13 | TR 1200M45MM LK H K/L | 24.00 | 22.00 | 24.00 | 130.00 | 34.00 | |||
15 | 14 | BTR-100***8 RRT-DE34230 | 25.00 | 23.00 | 25.00 | 140.00 | 35.00 | |||
16 | 15 | BTR-100***8 RRT-DE34231 | 26.00 | 24.00 | 26.00 | 150.00 | 36.00 | |||
17 | 16 | BTR-100***8 RRT-DE34232 | 27.00 | 25.00 | 27.00 | 160.00 | 37.00 | |||
18 | 17 | BTR-100***8 RRT-DE34233 | 28.00 | 26.00 | 28.00 | 170.00 | 38.00 | |||
19 | 18 | BTR-100***8 RRT-DE34234 | 29.00 | 27.00 | 29.00 | 180.00 | 39.00 | |||
20 | 19 | TR 2.5M100**123H K/LM | 30.00 | 28.00 | 30.00 | 190.00 | 40.00 | |||
21 | 20 | VMTR 1200S45 MN 123 | 31.00 | 29.00 | 31.00 | 200.00 | 41.00 | |||
22 | 21 | CCMTR 12-200M45 MM 123H K/L | 32.00 | 30.00 | 32.00 | 210.00 | 42.00 | |||
23 | 22 | CCMTR 12-200M45 MM-200 | 33.00 | 31.00 | 33.00 | 220.00 | 43.00 | |||
STOCK |
TT.xlsm | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | |||
1 | S.N | ITEM | QTY | 08/01/2024 | 09/01/2024 | 10/01/2024 | 11/01/2024 | 12/01/2024 | 13/01/2024 | 14/01/2024 | 15/01/2024 | 16/01/2024 | ||
2 | ||||||||||||||
3 | ||||||||||||||
4 | ||||||||||||||
5 | ||||||||||||||
6 | ||||||||||||||
7 | ||||||||||||||
8 | ||||||||||||||
9 | ||||||||||||||
10 | ||||||||||||||
11 | ||||||||||||||
12 | ||||||||||||||
13 | ||||||||||||||
14 | ||||||||||||||
15 | ||||||||||||||
16 | ||||||||||||||
17 | ||||||||||||||
18 | ||||||||||||||
19 | ||||||||||||||
20 | ||||||||||||||
21 | ||||||||||||||
22 | ||||||||||||||
23 | ||||||||||||||
STOCK_JAN |
TT.xlsm | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | |||
1 | S.N | ITEM | QTY | 08/02/2024 | 10/02/2024 | 11/02/2024 | 11/02/2024 | 12/02/2024 | 13/02/2024 | 14/02/2024 | 15/02/2024 | 16/02/2024 | ||
2 | ||||||||||||||
3 | ||||||||||||||
4 | ||||||||||||||
5 | ||||||||||||||
6 | ||||||||||||||
7 | ||||||||||||||
8 | ||||||||||||||
9 | ||||||||||||||
10 | ||||||||||||||
11 | ||||||||||||||
12 | ||||||||||||||
13 | ||||||||||||||
14 | ||||||||||||||
15 | ||||||||||||||
16 | ||||||||||||||
17 | ||||||||||||||
18 | ||||||||||||||
19 | ||||||||||||||
20 | ||||||||||||||
21 | ||||||||||||||
22 | ||||||||||||||
23 | ||||||||||||||
STOCK_FEB |
TT.xlsm | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | |||
1 | S.N | ITEM | QTY | 11/03/2024 | 12/03/2024 | 13/03/2024 | 14/03/2024 | 15/03/2024 | 16/03/2024 | 17/03/2024 | 18/03/2024 | 19/03/2024 | 20/03/2024 | ||
2 | |||||||||||||||
3 | |||||||||||||||
4 | |||||||||||||||
5 | |||||||||||||||
6 | |||||||||||||||
7 | |||||||||||||||
8 | |||||||||||||||
9 | |||||||||||||||
10 | |||||||||||||||
11 | |||||||||||||||
12 | |||||||||||||||
13 | |||||||||||||||
14 | |||||||||||||||
15 | |||||||||||||||
16 | |||||||||||||||
17 | |||||||||||||||
18 | |||||||||||||||
19 | |||||||||||||||
20 | |||||||||||||||
21 | |||||||||||||||
22 | |||||||||||||||
23 | |||||||||||||||
STOCK_MAR |
result in STOCK_JAN if the current month is JAN sheet when run the macro
[
TT.xlsm | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | |||
1 | S.N | ITEM | QTY | 08/01/2024 | 09/01/2024 | 10/01/2024 | 11/01/2024 | 12/01/2024 | 13/01/2024 | 14/01/2024 | 15/01/2024 | 16/01/2024 | ||
2 | 1 | CTR 12-200M45 MM 123H K/L | 22.00 | |||||||||||
3 | 2 | CCTR 12-200M45 MM 123H K/L | 23.00 | |||||||||||
4 | 3 | TR 200M45MM LK H K/L | 24.00 | |||||||||||
5 | 4 | TR 200M451 NMM LK H K/L | 25.00 | |||||||||||
6 | 5 | TTR 12200S45 MN 123 | 26.00 | |||||||||||
7 | 6 | TR 1425/148V MN 123H K/L | 27.00 | |||||||||||
8 | 7 | TR 200M45 MM 123H K/L SS | 28.00 | |||||||||||
9 | 8 | TR 2.5M100* 123H K/L | 29.00 | |||||||||||
10 | 9 | TR 2.5M100**123H K/L | 30.00 | |||||||||||
11 | 10 | TRMN 22.5M100* 123H K/L | 31.00 | |||||||||||
12 | 11 | TTRM 12200S45 MN 1234 | 32.00 | |||||||||||
13 | 12 | TTRR 1200S45 MN 123 | 33.00 | |||||||||||
14 | 13 | TR 1200M45MM LK H K/L | 34.00 | |||||||||||
15 | 14 | BTR-100***8 RRT-DE34230 | 35.00 | |||||||||||
16 | 15 | BTR-100***8 RRT-DE34231 | 36.00 | |||||||||||
17 | 16 | BTR-100***8 RRT-DE34232 | 37.00 | |||||||||||
18 | 17 | BTR-100***8 RRT-DE34233 | 38.00 | |||||||||||
19 | 18 | BTR-100***8 RRT-DE34234 | 39.00 | |||||||||||
20 | 19 | TR 2.5M100**123H K/LM | 40.00 | |||||||||||
21 | 20 | VMTR 1200S45 MN 123 | 41.00 | |||||||||||
22 | 21 | CCMTR 12-200M45 MM 123H K/L | 42.00 | |||||||||||
23 | 22 | CCMTR 12-200M45 MM-200 | 43.00 | |||||||||||
STOCK_JAN |
and if fill others columns in STOCK_JAN sheet will copy to next sheet STOCK_FEB if the current month is FEB like this
TT.xlsm | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | |||
1 | S.N | ITEM | QTY | 08/01/2024 | 09/01/2024 | 10/01/2024 | 11/01/2024 | 12/01/2024 | 13/01/2024 | 14/01/2024 | 15/01/2024 | 16/01/2024 | ||
2 | 1 | CTR 12-200M45 MM 123H K/L | 22.00 | 23.00 | 20.00 | |||||||||
3 | 2 | CCTR 12-200M45 MM 123H K/L | 23.00 | 10.00 | 30.00 | |||||||||
4 | 3 | TR 200M45MM LK H K/L | 24.00 | 12.00 | 40.00 | |||||||||
5 | 4 | TR 200M451 NMM LK H K/L | 25.00 | 14.00 | 50.00 | |||||||||
6 | 5 | TTR 12200S45 MN 123 | 26.00 | 16.00 | 60.00 | |||||||||
7 | 6 | TR 1425/148V MN 123H K/L | 27.00 | 18.00 | 70.00 | |||||||||
8 | 7 | TR 200M45 MM 123H K/L SS | 28.00 | 20.00 | 80.00 | |||||||||
9 | 8 | TR 2.5M100* 123H K/L | 29.00 | 22.00 | 90.00 | |||||||||
10 | 9 | TR 2.5M100**123H K/L | 30.00 | 24.00 | 100.00 | |||||||||
11 | 10 | TRMN 22.5M100* 123H K/L | 31.00 | 26.00 | 110.00 | |||||||||
12 | 11 | TTRM 12200S45 MN 1234 | 32.00 | 28.00 | 120.00 | |||||||||
13 | 12 | TTRR 1200S45 MN 123 | 33.00 | 30.00 | 130.00 | |||||||||
14 | 13 | TR 1200M45MM LK H K/L | 34.00 | 32.00 | 140.00 | |||||||||
15 | 14 | BTR-100***8 RRT-DE34230 | 35.00 | 34.00 | 150.00 | |||||||||
16 | 15 | BTR-100***8 RRT-DE34231 | 36.00 | 36.00 | 160.00 | |||||||||
17 | 16 | BTR-100***8 RRT-DE34232 | 37.00 | 38.00 | 170.00 | |||||||||
18 | 17 | BTR-100***8 RRT-DE34233 | 38.00 | 40.00 | 180.00 | |||||||||
19 | 18 | BTR-100***8 RRT-DE34234 | 39.00 | 42.00 | 190.00 | |||||||||
20 | 19 | TR 2.5M100**123H K/LM | 40.00 | 44.00 | 200.00 | |||||||||
21 | 20 | VMTR 1200S45 MN 123 | 41.00 | 46.00 | 210.00 | |||||||||
22 | 21 | CCMTR 12-200M45 MM 123H K/L | 42.00 | 48.00 | 220.00 | |||||||||
23 | 22 | CCMTR 12-200M45 MM-200 | 43.00 | 50.00 | 230.00 | |||||||||
STOCK_JAN |
the result in STOCK_FEB sheet when run macro again like this
TT.xlsm | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | |||
1 | S.N | ITEM | QTY | 08/02/2024 | 10/02/2024 | 11/02/2024 | 11/02/2024 | 12/02/2024 | 13/02/2024 | 14/02/2024 | 15/02/2024 | 16/02/2024 | ||
2 | 1 | CTR 12-200M45 MM 123H K/L | 20.00 | |||||||||||
3 | 2 | CCTR 12-200M45 MM 123H K/L | 30.00 | |||||||||||
4 | 3 | TR 200M45MM LK H K/L | 40.00 | |||||||||||
5 | 4 | TR 200M451 NMM LK H K/L | 50.00 | |||||||||||
6 | 5 | TTR 12200S45 MN 123 | 60.00 | |||||||||||
7 | 6 | TR 1425/148V MN 123H K/L | 70.00 | |||||||||||
8 | 7 | TR 200M45 MM 123H K/L SS | 80.00 | |||||||||||
9 | 8 | TR 2.5M100* 123H K/L | 90.00 | |||||||||||
10 | 9 | TR 2.5M100**123H K/L | 100.00 | |||||||||||
11 | 10 | TRMN 22.5M100* 123H K/L | 110.00 | |||||||||||
12 | 11 | TTRM 12200S45 MN 1234 | 120.00 | |||||||||||
13 | 12 | TTRR 1200S45 MN 123 | 130.00 | |||||||||||
14 | 13 | TR 1200M45MM LK H K/L | 140.00 | |||||||||||
15 | 14 | BTR-100***8 RRT-DE34230 | 150.00 | |||||||||||
16 | 15 | BTR-100***8 RRT-DE34231 | 160.00 | |||||||||||
17 | 16 | BTR-100***8 RRT-DE34232 | 170.00 | |||||||||||
18 | 17 | BTR-100***8 RRT-DE34233 | 180.00 | |||||||||||
19 | 18 | BTR-100***8 RRT-DE34234 | 190.00 | |||||||||||
20 | 19 | TR 2.5M100**123H K/LM | 200.00 | |||||||||||
21 | 20 | VMTR 1200S45 MN 123 | 210.00 | |||||||||||
22 | 21 | CCMTR 12-200M45 MM 123H K/L | 220.00 | |||||||||||
23 | 22 | CCMTR 12-200M45 MM-200 | 230.00 | |||||||||||
STOCK_FEB |
and if the current month is MAR then will copy from STOCK_FEB sheet and add MAR sheet like this
TT.xlsm | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | |||
1 | S.N | ITEM | QTY | 11/03/2024 | 12/03/2024 | 13/03/2024 | 14/03/2024 | 15/03/2024 | 16/03/2024 | 17/03/2024 | 18/03/2024 | 19/03/2024 | 20/03/2024 | ||
2 | 1 | CTR 12-200M45 MM 123H K/L | 20.00 | ||||||||||||
3 | 2 | CCTR 12-200M45 MM 123H K/L | 30.00 | ||||||||||||
4 | 3 | TR 200M45MM LK H K/L | 40.00 | ||||||||||||
5 | 4 | TR 200M451 NMM LK H K/L | 50.00 | ||||||||||||
6 | 5 | TTR 12200S45 MN 123 | 60.00 | ||||||||||||
7 | 6 | TR 1425/148V MN 123H K/L | 70.00 | ||||||||||||
8 | 7 | TR 200M45 MM 123H K/L SS | 80.00 | ||||||||||||
9 | 8 | TR 2.5M100* 123H K/L | 90.00 | ||||||||||||
10 | 9 | TR 2.5M100**123H K/L | 100.00 | ||||||||||||
11 | 10 | TRMN 22.5M100* 123H K/L | 110.00 | ||||||||||||
12 | 11 | TTRM 12200S45 MN 1234 | 120.00 | ||||||||||||
13 | 12 | TTRR 1200S45 MN 123 | 130.00 | ||||||||||||
14 | 13 | TR 1200M45MM LK H K/L | 140.00 | ||||||||||||
15 | 14 | BTR-100***8 RRT-DE34230 | 150.00 | ||||||||||||
16 | 15 | BTR-100***8 RRT-DE34231 | 160.00 | ||||||||||||
17 | 16 | BTR-100***8 RRT-DE34232 | 170.00 | ||||||||||||
18 | 17 | BTR-100***8 RRT-DE34233 | 180.00 | ||||||||||||
19 | 18 | BTR-100***8 RRT-DE34234 | 190.00 | ||||||||||||
20 | 19 | TR 2.5M100**123H K/LM | 200.00 | ||||||||||||
21 | 20 | VMTR 1200S45 MN 123 | 210.00 | ||||||||||||
22 | 21 | CCMTR 12-200M45 MM 123H K/L | 220.00 | ||||||||||||
23 | 22 | CCMTR 12-200M45 MM-200 | 230.00 | ||||||||||||
STOCK_MAR |
I hope finding solution from experts soon
thanks.