Create Workbooks and Worksheets with specific formats

Blaster1

New Member
Joined
Sep 11, 2021
Messages
14
Office Version
  1. 365
Platform
  1. Windows
Hello All,

Need your help with a VBA Code please.
See below tables and requirement of code to do the following:

1) Check table1 and create 6 workbooks.
a. Workbook 1 named AB-01 and has two worksheets (AB-01108 and AB-01115)
b. Workbook 2 named AB-02 and has four worksheets (AB-02112, AB-02113, AB-02114 and AB-02115)
c. Workbook 3 named AB-04 and has two worksheets (AB-04106 and AB-04110)
d. Workbook 4 named AB-05 and has two worksheets (AB-05113 and AB-05157)
e. Workbook 5 named AB-06 and has two worksheets (AB-06117 and AB-06119)
f. Workbook 6 named AB-16 and has one worksheet (AB-16120)
Note, Original file have hundreds of entries so logic will be to look at each name in columns A, and then create a new work book whenever I have "AB-XX"; XX is a new number like 01, 02, 14, 16 etc... if the number is repeated many times, then those will be worksheets in initial workbook ... i.e. if I have 6 rows all starting with AB-01 then one workbook with 6 worksheets inside workbook 01.


2) Each worksheet should be of the same format of table 2 below.
a. In table 2, Column A rows should have the same exact names as Column A of table 1.
b. In table 2, Columns C, D, E and F should have fixed text.
c. In table 2, Column G should have the units of 1st row in table 1.
d. In table 2, Column H should have the figures extracted from table 1 per unit.
e. In table 2, Column I should be equal to Column H in table 2.
f. In table 2, Columns M, N & O should have respectivley: "John Smith", "Date", "John Smith" with Mistral Font.
g. In table 2, select whole table from A7 to P7 and replace all blank cells with "Text".
h. In table 2, Field E2 should have same name of all TEXT after AB-XXXXX.
i. In table 2, Field C2 should have all number after it's AB-, ie for AB-01108 ABC-XYZ-FFF-01, C2 should be 01108
j. In table 2, Field B2 should be last two numbers of C2 i.e. 08 in above example.
k. In table 2, Field E3 should be fixed "Text".
l. In table 2, lock all columns to specific ColumnWidth per each columns (I will insert the value on the code).
m. Save all and quit.

TABLE 1
NameUnit 1Unit 2Unit 3Unit AUnit BUnit C
AB-01108 ABC-XYZ-FFF-0114.0 ABC8.3 DEF0.6 GHI0.056.024.9
AB-01115 ABC-XYZ-FFF-0238.0 ABC24.3 DEF9.2 GHI0.0---74.6
AB-02112 ABD-XYZ-FFF-0111.9 ABC2.1 DEF0.1 GHI0.056.021.2
AB-02113 ABD-XYZ-FFF-0210.6 ABC2.2 DEF0.1 GHI0.044.021.1
AB-02114 ABX-XYZ-FFF-010.0 ABC0.0 DEF0.0 GHI10.042.00.9
AB-02115 ABZ-XYZ-FFF-0111.2 ABC4.7 DEF0.1 GHI0.0---21.1
AB-04106 ABX-XYZ-FFF-0942.0 ABC0.5 DEF0.1 GHI42.050.084.0
AB-04110 ABX-XYZ-FFF-0312.5 ABC7.0 DEF0.3 GHI0.050.024.9
AB-05113 TRE-VSX-TRRR-020.0 ABC0.0 DEF0.0 GHI---50.00.1
AB-05157 TRE-VSX-TRRR-050.0 ABC0.0 DEF0.0 GHI10.036.0---
AB-06117 YTYT-VMM-TRPP-010.0 ABC0.0 DEF0.0 GHI42.056.00.6
AB-06119 YTYT-VMM-TRPP-0510.0 ABC0.7 DEF0.0 GHI10.027.00.2
AB-16120 YTYT-VMM-TRPP-1910.0 ABC0.7 DEF0.0 GHI10.027.00.2


TABLE 2
first 2full idBusNameModel
0801108 ABC-XYZ-FFF-01
Text
Device InformationNumbersN/AInfo
ABCDEFGHIJKLMNOP
AB-01108 ABC-XYZ-FFF-01CDETUnit 12222John SmithDateJohn Smith
AB-01108 ABC-XYZ-FFF-01CJETUnit 20.90.9John SmithDateJohn Smith
AB-01108 ABC-XYZ-FFF-01CGETUnit 30.10.1John SmithDateJohn Smith
AB-01108 ABC-XYZ-FFF-01CLETUnit A2222John SmithDateJohn Smith
AB-01108 ABC-XYZ-FFF-01COETUnit B2222John SmithDateJohn Smith
AB-01108 ABC-XYZ-FFF-01CPEUUnit C1414John SmithDateJohn Smith
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Those are very detailed specifications. I can't help but wonder if you might have been able to manually make the workbook yourself quicker than it took to type those instructions out.
You could have just pressed the record macro button as you started to make the workbook, and it would have made the VBA code for you.

Oh well. I'll be interested to see if anyone volunteers to do your work for you.
 
Upvote 0
Those are very detailed specifications. I can't help but wonder if you might have been able to manually make the workbook yourself quicker than it took to type those instructions out.
You could have just pressed the record macro button as you started to make the workbook, and it would have made the VBA code for you.

Oh well. I'll be interested to see if anyone volunteers to do your work for you.
Thanks Dan, I can do it myself but that would be for one file only. I lack the knowledge to create a logic so it would do the same for all rows as original document contain hundreds of entries.
Thanks anyway, cheers.
 
Upvote 0
You don't really need to - the Record Macro button will be able to do it for you.
 
Upvote 0

Forum statistics

Threads
1,214,636
Messages
6,120,664
Members
448,976
Latest member
sweeberry

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