clear contents cells for specific sheets except last sheet when save new file

leap out

Active Member
Joined
Dec 4, 2020
Messages
275
Office Version
  1. 2016
  2. 2010
Hi
I want to export file as xlsm with keep the same sheets names and formatting , but should replace data form summary sheet with stock sheet and clear sheets (sales,pur,RETURNS,SUMMARY) with keep the same formatting and when save the file should be file name STOCK-& current year . and should replace data every time run the macro based on current year.

original data

INVEN with single search v0 c.xlsm
ABCDEF
1itemCODEBRANDTYPEMANUFACTUREQTY
21AA-110W40 208LQ8EU2222
32AA-215W40 208LCASSU400
43AA-35W30 208LQ8EU800
54AA-45W30 12x1LQ8EU600
65AA-510W40 208LENIIT300
76AA-65W30 4x4LQ8EU200
87AA-710W40 12x1LQ8EU120
98AA-815W40 12x1LCASSU450
109AA-910W40 12x1LENIIT890
1110AA-1010W40 4x4LQ8EU345
1211AA-1110W40 4x4LCASSU78
1312AA-1210W40 4x4LENIIT123
1413AA-135W40 4x4LQ8EU456
1514AA-145W40 4x4LCASSU678
1615AA-155W40 4x4LENIIT1234
1716AA-1620W50 4x4LQ8EU456
STOCK


INVEN with single search v0 c.xlsm
ABCDEF
1DATECODEBRANDTYPEMANUFACTURESALES
201/01/2021AA-110W40 208LQ8EU100
302/01/2021AA-215W40 208LCASSU50
403/01/2021AA-35W30 208LQ8EU280
504/01/2021AA-45W30 12x1LQ8EU300
605/01/2021AA-510W40 208LENIIT80
706/01/2021AA-65W30 4x4LQ8EU20
807/01/2021AA-710W40 12x1LQ8EU20
908/01/2021AA-815W40 12x1LCASSU20
1009/01/2021AA-910W40 12x1LENIIT876
1110/01/2021AA-1010W40 4x4LQ8EU345
1211/01/2021AA-1110W40 4x4LCASSU123
1312/01/2021AA-1210W40 4x4LENIIT78
1413/01/2021AA-135W40 4x4LQ8EU300
1514/01/2021AA-145W40 4x4LCASSU34
1615/01/2021AA-155W40 4x4LENIIT23
1716/01/2021AA-1620W50 4x4LQ8EU56
1817/01/2021AA-110W40 208LQ8EU100
sales


INVEN with single search v0 c.xlsm
ABCDEF
1DATECODEBRANDTYPEMANUFACTUREPURCHASE
204/02/2021AA-110W40 208LQ8EU55
305/02/2021AA-215W40 208LCASSU20
406/02/2021AA-35W30 208LQ8EU10
507/02/2021AA-45W30 12x1LQ8EU10
608/02/2021AA-510W40 208LENIIT3
709/02/2021AA-65W30 4x4LQ8EU4
810/02/2021AA-710W40 12x1LQ8EU45
911/02/2021AA-815W40 12x1LCASSU8
1012/02/2021AA-910W40 12x1LENIIT1
1113/02/2021AA-1010W40 4x4LQ8EU100
1214/02/2021AA-1110W40 4x4LCASSU20
1315/02/2021AA-1210W40 4x4LENIIT100
1416/02/2021AA-135W40 4x4LQ8EU44
1517/02/2021AA-145W40 4x4LCASSU20
1618/02/2021AA-155W40 4x4LENIIT50
1719/02/2021AA-1620W50 4x4LQ8EU12
1820/02/2021AA-1720W50 4x4LCASSU9
1921/02/2021AA-1820W50 4x4LENIIT4
2022/02/2021AA-110W40 208LQ8EU55
pur



INVEN with single search v0 c.xlsm
ABCDEF
1itemCODEBRANDTYPEMANUFACTUREreturns
205/04/2021AA-910W40 12x1LENIIT20
306/04/2021AA-1010W40 4x4LQ8EU30
407/04/2021AA-1110W40 4x4LCASSU40
508/04/2021AA-45W30 12x1LQ8EU10
609/04/2021AA-45W30 12x1LQ8EU11
RETURNS


INVEN with single search v0 c.xlsm
ABCDEFGHIJ
1itemCODEBRANDTYPEMANUFACTURESTOCKSALESPURRETURNSBALANCE
21AA-110W40 208LQ8EU22222001102132
32AA-215W40 208LCASSU4005020370
43AA-35W30 208LQ8EU80028010530
54AA-45W30 12x1LQ8EU6003001021331
65AA-510W40 208LENIIT300803223
76AA-65W30 4x4LQ8EU200204184
87AA-710W40 12x1LQ8EU1202045145
98AA-815W40 12x1LCASSU450208438
109AA-910W40 12x1LENIIT89087612035
1110AA-1010W40 4x4LQ8EU34534510030130
1211AA-1110W40 4x4LCASSU78123204015
1312AA-1210W40 4x4LENIIT12378100145
1413AA-135W40 4x4LQ8EU45630044200
1514AA-145W40 4x4LCASSU6783420664
1615AA-155W40 4x4LENIIT123423501261
1716AA-1620W50 4x4LQ8EU4565612412
1817AA-1720W50 4x4LCASSU99
1918AA-1820W50 4x4LENIIT44
SUMMARY



result should save file as xlsm
STOCK-2023.xlsm
ABCDEFGHIJ
1itemCODEBRANDTYPEMANUFACTURESTOCKSALESPURRETURNSBALANCE
21AA-110W40 208LQ8EU22222001102132
32AA-215W40 208LCASSU4005020370
43AA-35W30 208LQ8EU80028010530
54AA-45W30 12x1LQ8EU6003001021331
65AA-510W40 208LENIIT300803223
76AA-65W30 4x4LQ8EU200204184
87AA-710W40 12x1LQ8EU1202045145
98AA-815W40 12x1LCASSU450208438
109AA-910W40 12x1LENIIT89087612035
1110AA-1010W40 4x4LQ8EU34534510030130
1211AA-1110W40 4x4LCASSU78123204015
1312AA-1210W40 4x4LENIIT12378100145
1413AA-135W40 4x4LQ8EU45630044200
1514AA-145W40 4x4LCASSU6783420664
1615AA-155W40 4x4LENIIT123423501261
1716AA-1620W50 4x4LQ8EU4565612412
1817AA-1720W50 4x4LCASSU99
1918AA-1820W50 4x4LENIIT44
STOCK


STOCK-2023.xlsm
ABCDEF
1DATECODEBRANDTYPEMANUFACTURESALES
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
sales


STOCK-2023.xlsm
ABCDEF
1DATECODEBRANDTYPEMANUFACTUREPURCHASE
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
pur


STOCK-2023.xlsm
ABCDEF
1itemCODEBRANDTYPEMANUFACTUREreturns
2
3
4
5
6
RETURNS


STOCK-2023.xlsm
ABCDEFGHIJ
1itemCODEBRANDTYPEMANUFACTURESTOCKSALESPURRETURNSBALANCE
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
SUMMARY

I hope this make sense
thanks
 
Last edited:

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
You might get some assistance if you could post the workbook. Otherwise someone that wants to help has to recreate everything to try to put together code needed. Even if there is fake data in the workbook that would help. Also, maybe try to explain the need again, differenty, so it might be more clear.

You are allowed to post a workbook via a link to it on Dropbox or 1Drive. Use the link icon above.
 
Upvote 0
Is this what the macro should do?

Goal: export file as xlsm named like this STOCK_2023 where 2023 is the current year. That file contains current Stock data that is data put into the Summary Sheet.
Details:
1. Keep the same named sheets with formatting.
2. Replace data that is in the summary sheet with data from the stock sheet.
3. Clear data from sheets a. sales, b. pur, c. RETURNS but keep the same formatting.

Should data transferred from SUMMARY be added to the bottom of the SUMMARY sheet or should it replace the data in the SUMMARY sheet?

Data in the STOCK sheet is not changed by the macro?
 
Upvote 0
Should data transferred from SUMMARY be added to the bottom of the SUMMARY sheet or should it replace the data in the SUMMARY sheet?
should replace data .
Data in the STOCK sheet is not changed by the macro?
I'm not sure what you mean !
when run the macro should replace data in stock sheet if data change in summary sheet .
 
Upvote 0
I would like to help you but I have to understand what you want. And no your need details are not clear, maybe because I am not so smart.

To confirm...the main objective is to 1. clear data from the SUMMARY sheet 2. transfer data from the STOCK sheet to SUMMARY sheet, 3. clear data from the STOCK, sales, pur and RETURNS sheets, keep all formatting.

BUT, the STOCK and SUMMARY sheets have different columns. From your workbook,

Columns in STOCK are: ITEM, CODE, BRAND, TYPE, MANUFACTURE, QTY.

Columns in SUMMARY are: ITEM, CODE, BRAND, TYPE, MANUFACTURE, STOCK, SALES, PUR, RETURNS, BALANCE

So, to restate the need: Columns transferred from STOCK sheet to the SUMMARY sheet include ITEM, CODE, BRAND, TYPE, MANUFACTURE and data in the the other columns in SUMMARY sheet are cleared. Then data is cleared from the STOCK, sales, pur and RETURNS sheets, keeping all formatting.
 
Upvote 0
Also, I am guessing that data in column QTY in STOCK sheet are copied into column STOCK in the SUMMARY sheet.
 
Upvote 0
1. clear data from the SUMMARY sheet
yes
2. transfer data from the STOCK sheet to SUMMARY sheet
no should transfer data from SUMMARY sheet to STOCK sheet (just see the last picture before result and the first picture for result )
BUT, the STOCK and SUMMARY sheets have different columns. From your workbook,
yes , don't change the headers , just clear from row 2 for every sheet.
Also, I am guessing that data in column QTY in STOCK sheet are copied into column STOCK in the SUMMARY sheet.
as I said in point2
 
Upvote 0
I guess you are frustrated with me for being so dumb. I am trying my best to understand what happens. Maybe there is a language problem?

Is THIS what the macro should do?

1. All data is cleared from STOCK, SALES, pur, RETURNs sheets keeping formatting and column headers.

2. Data from SUMMARY sheet -- including all 10 columns from the SUMMARY sheet -- is transferred to the STOCK sheet.

3. After data from SUMMARY sheet is transferred to the STOCK sheet then clear data from the SUMMARY sheet.

Note:
BEFORE the data from the SUMMARY sheet is transferred to the STOCK sheet there are six headers in the STOCK sheet: 1. item, 2. CODE, 3. BRAND, 4. TYPE, 5. MANUFACTURE, 6. QTY.

AFTER transferring data from SUMMARY sheet to STOCK sheet the STOCK sheet will then have 10 headers:
1. item, 2. CODE, 3. BRAND, 4. TYPE, 5. MANUFACTURE, 6. STOCK, 7. SALES, 8. PUR, 9. RETURNS, 10. BALANCE.

I hope that I understand now!?
 
Upvote 0
yes all of your points are correct.

as to the note , my apologies!! a
bout different columns for STOCK sheet before and after despite of you made me attention more than one time but I don't answer you Thinking that all things are ok . I don't note it in OP , sorry !
 
Upvote 0

Forum statistics

Threads
1,215,972
Messages
6,128,030
Members
449,414
Latest member
sameri

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