sort data based on two dates and sheet name from sheet to another

KalilMe

Active Member
Joined
Mar 5, 2021
Messages
382
Office Version
  1. 2016
Platform
  1. Windows
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

ورقة عمل Microsoft Excel جديد ‫(3)‬.xlsx
ABCDEFGHIJ
1ITEMDATENAMEINVOICEGOODSTYPEPRQTYUNITTOTAL
2125/05/2023CR-1000STVG-1000ATRAM1MTR5.0025.00125.00
3225/05/2023CR-1000STVG-1000ATRAM2PO4.0035.00140.00
4325/05/2023CR-1000STVG-1000ATRAM1SO2.0045.0090.00
5TOTAL25/05/2023CR-1000STVG-1000355.00
6128/05/2023CR-1001STVG-1001ATRAM1GR2.0023.0046.00
7228/05/2023CR-1001STVG-1001ATRAM2PO2.0035.0070.00
8TOTAL28/05/2023CR-1001STVG-1001116.00
9128/07/2023CR-1000STVG-1002ATRAM1MTR2.0025.0050.00
10228/07/2023CR-1000STVG-1002ATRAM2PO2.0035.0070.00
11328/07/2023CR-1000STVG-1002ATRAM1SO2.0045.0090.00
12TOTAL28/07/2023CR-1000STVG-1002210.00
13128/07/2023CR-1000STVG-1003ATRAM2SO2.0045.00330.00
14TOTAL28/07/2023CR-1000STVG-1003330.00
15127/08/2023CR-1002STVG-1004VBGFHJH1HGF2.0040.0080.00
16227/08/2023CR-1002STVG-1004ASDWMMNSO2.0050.00100.00
17TOTAL27/08/2023CR-1002STVG-1004180.00
BUYING


pop Microsoft Excel (3)‬.xlsx
ABCDEFGHIJ
1ITEMDATENAMEINVOICEGOODSTYPEPRQTYUNITTOTAL
2127/05/2023CR-1000FRVG-10000ATRAM1MTR2.0030.0060.00
3227/05/2023CR-1000FRVG-10000ATRAM2PO2.0040.0080.00
4TOTAL27/05/2023CR-1000FRVG-10000140.00
5129/05/2023CR-1001FRVG-10001ATRAM1GR1.0030.0030.00
6TOTAL29/05/2023CR-1001FRVG-1000130.00
7130/07/2023CR-1000FRVG-10002ATRAM2PO1.0040.0040.00
8230/07/2023CR-1000FRVG-10002ATRAM1SO1.0050.0050.00
9TOTAL30/07/2023CR-1000FRVG-1000290.00
10130/07/2023MMR-1000FRVG-10003ATRAM2SO2.0050.00100.00
11TOTAL30/07/2023MMR-1000FRVG-10003100.00
SALES


data should be empty when cells C3,E3,G3
pop Microsoft Excel ‫(3)‬.xlsx
ABCDEFG
2FIRST DATELAST DATESHEET NAME
3
4
5ITEMDATEINVOICETOTAL
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
ABCDEFG
2FIRST DATELAST DATESHEET NAME
325/05/202328/05/2023BUYING
4
5ITEMDATEINVOICETOTAL
6125/05/2023STVG-1000355.00
7228/05/2023STVG-1001116.00
8TOTAL471.00
SH2


and if I change dates then will be like this
pop Microsoft Excel ‫(3)‬.xlsx
ABCDEFG
2FIRST DATELAST DATESHEET NAME
328/07/202327/08/2023BUYING
4
5ITEMDATEINVOICETOTAL
6125/05/2023STVG-1000355.00
7228/05/2023STVG-1001116.00
8328/07/2023STVG-1002210.00
9428/07/2023STVG-1003330.00
10527/08/2023STVG-1004180.00
11TOTAL
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
ABCDEFG
2FIRST DATELAST DATESHEET NAME
325/05/202328/05/2023BUYING
4
5ITEMDATEINVOICETOTAL
6125/05/2023STVG-1000355.00
7228/05/2023STVG-1001116.00
8328/07/2023STVG-1002210.00
9428/07/2023STVG-1003330.00
10527/08/2023STVG-1004180.00
11TOTAL
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:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

You have been warned enough times. Please post the link & in future do it without having to be told.
 
Upvote 0

Forum statistics

Threads
1,223,956
Messages
6,175,612
Members
452,661
Latest member
Nonhle

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