Macro to create a file from base file if data is availabe in defined columns

shansakhi

Active Member
Joined
Apr 5, 2008
Messages
276
Office Version
  1. 365
Platform
  1. Windows
Hi All,

Good Evening.

I require your help for creating Macro.

Below is the base file and the highlighted row 1 are the headers.

I want to prepare a another file based on the base file if data is available under headers S A/C, A A/C, G A/C and W A/C.
CODE1PRO 1CODE DetailsCompleted DateSSDSEDTSDTEDFBRow NoS A/CA A/CG A/CW A/C
KW1KWI1ABCD6-Aug-146-Aug-1410-Aug-147-Aug-1430-Sep-14M1KRPW----
KW1KWI1ABCD6-Aug-146-Aug-1410-Aug-147-Aug-1430-Sep-14E1KRPW----
HD1HDS11Tejas Corp24-Aug-1425-Aug-1430-Jun-1425-Aug-1430-Jun-14FBR3GMJPGMJ0134661CHA-
HD1HDS11Tejas Corp24-Aug-1425-Aug-1430-Jun-1425-Aug-1430-Jun-14FBR4GMJPGMJ0134661CHA-
HD1HDS11Tejas Corp24-Aug-1425-Aug-1430-Jun-1425-Aug-1430-Jun-14FBR5GMJPGMJ0134661CHA-
HD1HDS11Tejas Corp24-Aug-1425-Aug-1430-Jun-1425-Aug-1430-Jun-14FBR6GMJPGMJ0134661CHA-
HD1HDS11Tejas Corp24-Aug-1425-Aug-1430-Jun-1425-Aug-1430-Jun-14FBR7GMJPGMJ0134661CHA-

<TBODY>
</TBODY>


Output File

In Output file the headers will be fixed... we need to populate the data from Base file under the correct heading if data is available in defined columns of Base file (mentioned above)
Sr noCode Detailscode 1G A/CA A/CW A/CS A/CFBR1FBR2FBR3FBR4FBR5FBR6FBR7M1E1SSDSEDTSDTEDPRO1Completed date
1Tejas CorpKW1CHA34661-GMJ01--GMJP1GMJP2GMJP3GMJP4GMJP5--25-Aug-1430-Jun-1425-Aug-1430-Jun-14HDS1124-Aug-14

<TBODY>
</TBODY>


Hope I am able to explain you the required.
Please feel free to ask me if you need any clarification....

Regards
Shan
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
So all columns for particular code are the same except FB and you want transpose it with added row number?

Could you review your example as it seems that require output is incorrect. If it is correct then I don't understand the logic behind it
 
Upvote 0
Thank you for replying.

I made some changes in the file. Please let me know if I am clear.

If you see there are 5 rows for Tejas Corp we would like to have only one row for Tejas Corp ... Data is available in S A/C, A A/C, G A/C hence we would like to exctract this.
For code details ABCD there is no data in S A/C, A A/C, G A/C or W A/C hence we are not considering the same.

Base File:
CODE1PRO 1CODE DetailsCompleted DateSSDSEDTSDTEDFBRow NoS A/CA A/CG A/CW A/C
KW1KWI1ABCD6-Aug-146-Aug-1410-Aug-147-Aug-1430-Sep-14M1KRPW----
KW1KWI1ABCD6-Aug-146-Aug-1410-Aug-147-Aug-1430-Sep-14E1KRPW----
HD1HDS11Tejas Corp24-Aug-1425-Aug-1430-Jun-1425-Aug-1430-Jun-14FBR3GMJP1GMJ0134661CHA-
HD1HDS11Tejas Corp24-Aug-1425-Aug-1430-Jun-1425-Aug-1430-Jun-14FBR4GMJP2GMJ0134661CHA-
HD1HDS11Tejas Corp24-Aug-1425-Aug-1430-Jun-1425-Aug-1430-Jun-14FBR5GMJP3GMJ0134661CHA-
HD1HDS11Tejas Corp24-Aug-1425-Aug-1430-Jun-1425-Aug-1430-Jun-14FBR6GMJP4GMJ0134661CHA-
HD1HDS11Tejas Corp24-Aug-1425-Aug-1430-Jun-1425-Aug-1430-Jun-14FBR7GMJP5GMJ0134661CHA-

<TBODY>
</TBODY>

Output File
Sr noCode Detailscode 1G A/CA A/CW A/CS A/CFBR1FBR2FBR3FBR4FBR5FBR6FBR7M1E1SSDSEDTSDTEDPRO1Completed date
1Tejas CorpHD1CHA34661-GMJ01--GMJP1GMJP2GMJP3GMJP4GMJP5--25-Aug-1430-Jun-1425-Aug-1430-Jun-14HDS1124-Aug-14

<TBODY>
</TBODY>
 
Upvote 0
Could you advice that there won't be any other columns name for FB but FBR1-FBR7, E1 and M1. So that if you will have another company it would have only one of those.
 
Upvote 0
Hi,
As of now we have fbr1-fbr7, M1,E1... In future we may hv some more. That we will add in to output file.
 
Upvote 0
It would be quite hard to create the code which will do this kind of analyses as well and add new columns. I can help with creating macro, but your request is complex and require lots of time.
 
Upvote 0
hi,
Thank you. The columns will be added by us. We will add all possible FB in the output file. The micro should only populate the data from base file to the fb columns ...
 
Upvote 0

Forum statistics

Threads
1,214,374
Messages
6,119,159
Members
448,870
Latest member
max_pedreira

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