Hi
I have data for about 7000 rows for each sheet. I think the better way could be by sort .
so I want filling cells dates in C3,E3 and sheet name in G3 , then should be brings date, invoice and total from the lastrow contains TOTAL word is existed in column A with insert TOTAL row to sum the whole amounts are existed in TOTAL column(D) as show in SH2 sheet.
if the cells C3,E3 ,G3 are empty then should clear data , but if the cell is just filled sheet name in G3 and C3,E3 are empty then should brings the all of data with insert TOTAL row to sum the whole amounts are existed in TOTAL column(D) as show in SH2 sheet . so every time run the macro should clear data in SH2 before b rings data when cell is just filled sheet name in G3 and C3,E3 are empty, but if the cells are filled then just copy to the bottom without repeat copying data are already copied.
the data
data should be empty when cells C3,E3,G3
first case when fill C3,E3,G3
and if I change dates then will be like this
as you see the different dates should copy to the bottom
but if I repeat writing the same dates for data have already copied then should not copy again like this
last thing I will add another sheets with the same structure like BUYING & SALES so the macro should implements for many sheets but when loop the sheets should start from sheet3 to last sheet because in my real project the sheets BUYING ,SALES ... start from third sheet .
I have data for about 7000 rows for each sheet. I think the better way could be by sort .
so I want filling cells dates in C3,E3 and sheet name in G3 , then should be brings date, invoice and total from the lastrow contains TOTAL word is existed in column A with insert TOTAL row to sum the whole amounts are existed in TOTAL column(D) as show in SH2 sheet.
if the cells C3,E3 ,G3 are empty then should clear data , but if the cell is just filled sheet name in G3 and C3,E3 are empty then should brings the all of data with insert TOTAL row to sum the whole amounts are existed in TOTAL column(D) as show in SH2 sheet . so every time run the macro should clear data in SH2 before b rings data when cell is just filled sheet name in G3 and C3,E3 are empty, but if the cells are filled then just copy to the bottom without repeat copying data are already copied.
the data
ورقة عمل Microsoft Excel جديد (3).xlsx | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | |||
1 | ITEM | DATE | NAME | INVOICE | GOODS | TYPE | PR | QTY | UNIT | TOTAL | ||
2 | 1 | 25/05/2023 | CR-1000 | STVG-1000 | ATR | AM1 | MTR | 5.00 | 25.00 | 125.00 | ||
3 | 2 | 25/05/2023 | CR-1000 | STVG-1000 | ATR | AM2 | PO | 4.00 | 35.00 | 140.00 | ||
4 | 3 | 25/05/2023 | CR-1000 | STVG-1000 | ATR | AM1 | SO | 2.00 | 45.00 | 90.00 | ||
5 | TOTAL | 25/05/2023 | CR-1000 | STVG-1000 | 355.00 | |||||||
6 | 1 | 28/05/2023 | CR-1001 | STVG-1001 | ATR | AM1 | GR | 2.00 | 23.00 | 46.00 | ||
7 | 2 | 28/05/2023 | CR-1001 | STVG-1001 | ATR | AM2 | PO | 2.00 | 35.00 | 70.00 | ||
8 | TOTAL | 28/05/2023 | CR-1001 | STVG-1001 | 116.00 | |||||||
9 | 1 | 28/07/2023 | CR-1000 | STVG-1002 | ATR | AM1 | MTR | 2.00 | 25.00 | 50.00 | ||
10 | 2 | 28/07/2023 | CR-1000 | STVG-1002 | ATR | AM2 | PO | 2.00 | 35.00 | 70.00 | ||
11 | 3 | 28/07/2023 | CR-1000 | STVG-1002 | ATR | AM1 | SO | 2.00 | 45.00 | 90.00 | ||
12 | TOTAL | 28/07/2023 | CR-1000 | STVG-1002 | 210.00 | |||||||
13 | 1 | 28/07/2023 | CR-1000 | STVG-1003 | ATR | AM2 | SO | 2.00 | 45.00 | 330.00 | ||
14 | TOTAL | 28/07/2023 | CR-1000 | STVG-1003 | 330.00 | |||||||
15 | 1 | 27/08/2023 | CR-1002 | STVG-1004 | VBGF | HJH1 | HGF | 2.00 | 40.00 | 80.00 | ||
16 | 2 | 27/08/2023 | CR-1002 | STVG-1004 | ASDW | MMN | SO | 2.00 | 50.00 | 100.00 | ||
17 | TOTAL | 27/08/2023 | CR-1002 | STVG-1004 | 180.00 | |||||||
BUYING |
pop Microsoft Excel (3).xlsx | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | |||
1 | ITEM | DATE | NAME | INVOICE | GOODS | TYPE | PR | QTY | UNIT | TOTAL | ||
2 | 1 | 27/05/2023 | CR-1000 | FRVG-10000 | ATR | AM1 | MTR | 2.00 | 30.00 | 60.00 | ||
3 | 2 | 27/05/2023 | CR-1000 | FRVG-10000 | ATR | AM2 | PO | 2.00 | 40.00 | 80.00 | ||
4 | TOTAL | 27/05/2023 | CR-1000 | FRVG-10000 | 140.00 | |||||||
5 | 1 | 29/05/2023 | CR-1001 | FRVG-10001 | ATR | AM1 | GR | 1.00 | 30.00 | 30.00 | ||
6 | TOTAL | 29/05/2023 | CR-1001 | FRVG-10001 | 30.00 | |||||||
7 | 1 | 30/07/2023 | CR-1000 | FRVG-10002 | ATR | AM2 | PO | 1.00 | 40.00 | 40.00 | ||
8 | 2 | 30/07/2023 | CR-1000 | FRVG-10002 | ATR | AM1 | SO | 1.00 | 50.00 | 50.00 | ||
9 | TOTAL | 30/07/2023 | CR-1000 | FRVG-10002 | 90.00 | |||||||
10 | 1 | 30/07/2023 | MMR-1000 | FRVG-10003 | ATR | AM2 | SO | 2.00 | 50.00 | 100.00 | ||
11 | TOTAL | 30/07/2023 | MMR-1000 | FRVG-10003 | 100.00 | |||||||
SALES |
data should be empty when cells C3,E3,G3
pop Microsoft Excel (3).xlsx | |||||||||
---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | |||
2 | FIRST DATE | LAST DATE | SHEET NAME | ||||||
3 | |||||||||
4 | |||||||||
5 | ITEM | DATE | INVOICE | TOTAL | |||||
6 | |||||||||
7 | |||||||||
8 | |||||||||
9 | |||||||||
10 | |||||||||
11 | |||||||||
12 | |||||||||
13 | |||||||||
14 | |||||||||
15 | |||||||||
16 | |||||||||
17 | |||||||||
18 | |||||||||
19 | |||||||||
20 | |||||||||
SH2 |
first case when fill C3,E3,G3
pop Microsoft Excel (3).xlsx | |||||||||
---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | |||
2 | FIRST DATE | LAST DATE | SHEET NAME | ||||||
3 | 25/05/2023 | 28/05/2023 | BUYING | ||||||
4 | |||||||||
5 | ITEM | DATE | INVOICE | TOTAL | |||||
6 | 1 | 25/05/2023 | STVG-1000 | 355.00 | |||||
7 | 2 | 28/05/2023 | STVG-1001 | 116.00 | |||||
8 | TOTAL | 471.00 | |||||||
SH2 |
and if I change dates then will be like this
pop Microsoft Excel (3).xlsx | |||||||||
---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | |||
2 | FIRST DATE | LAST DATE | SHEET NAME | ||||||
3 | 28/07/2023 | 27/08/2023 | BUYING | ||||||
4 | |||||||||
5 | ITEM | DATE | INVOICE | TOTAL | |||||
6 | 1 | 25/05/2023 | STVG-1000 | 355.00 | |||||
7 | 2 | 28/05/2023 | STVG-1001 | 116.00 | |||||
8 | 3 | 28/07/2023 | STVG-1002 | 210.00 | |||||
9 | 4 | 28/07/2023 | STVG-1003 | 330.00 | |||||
10 | 5 | 27/08/2023 | STVG-1004 | 180.00 | |||||
11 | TOTAL | ||||||||
SH2 |
as you see the different dates should copy to the bottom
but if I repeat writing the same dates for data have already copied then should not copy again like this
pop Microsoft Excel (3).xlsx | |||||||||
---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | |||
2 | FIRST DATE | LAST DATE | SHEET NAME | ||||||
3 | 25/05/2023 | 28/05/2023 | BUYING | ||||||
4 | |||||||||
5 | ITEM | DATE | INVOICE | TOTAL | |||||
6 | 1 | 25/05/2023 | STVG-1000 | 355.00 | |||||
7 | 2 | 28/05/2023 | STVG-1001 | 116.00 | |||||
8 | 3 | 28/07/2023 | STVG-1002 | 210.00 | |||||
9 | 4 | 28/07/2023 | STVG-1003 | 330.00 | |||||
10 | 5 | 27/08/2023 | STVG-1004 | 180.00 | |||||
11 | TOTAL | ||||||||
SH2 |
last thing I will add another sheets with the same structure like BUYING & SALES so the macro should implements for many sheets but when loop the sheets should start from sheet3 to last sheet because in my real project the sheets BUYING ,SALES ... start from third sheet .
Last edited: