I have common data in four files, call them A.csv, B.csv, C.csv & D.csv, that I want to move to a new file User.csv and repeat for all instances of "user". The files look like:
"User","Sal","First","Last","Attn","Country",/ /,"Ffapplied_","Group"
"CCD","","","NEW HOUSING","","",/ /,"",""
"CCD","","BOB & JANE","SMITH","","",/ /,"",""
"CCD","","","CAMBRIA HEIGHTS","C/O THE CORRESP","",/ /,"",""
"Evan","","BILL & PAT","ALEX","","",/ /,"",""
"Evan","","RICHARD & BARBARA","ANDERSON","","",/ /,"",""
"Halls","","SANDY","CRICKET","","",/ /,"",""
"Halls","MRS","FERN","MAXWELL","TAZOR HILLS","",/ /,"",""
"Halls","","HOWARD & GLADYS","TESLA","","",/ /,"",""
"Richard Bob","","","1040 WINDOW INC","","",/ /,"","no email"
"Richard Bob","","","CHAPEL UMC","","",/ /,"",""
"Richardson","","SCOTT & CAROL","BASSEL","","",/ /,"","email"
"Richardson","","","BEACON COMMUNITY CHURCH","","",/ /,"",""
"Richardson","","","FIRST STREET PLUMBING","C/O MR ROBERTS","",/ /,"",""
The above list is from file A.csv which has all 5 instances that will be in the output files to be created (CCD.csv, Evan.csv, etc). The other three files will NOT have all instances, i.e. B.csv will only have Evan and Richardson. All files are sorted by the first field "user" with the exception of the header in line one, which is present in all files.
The resultant files will look like: filename = CCD.csv
From File A.csv
"User","Sal","First","Last","Attn","Country",/ /,"Ffapplied_","Group"
"CCD","","","NEW HOUSING","","",/ /,"",""
"CCD","","BOB & JANE","SMITH","","",/ /,"",""
"CCD","","","CAMBRIA HEIGHTS","C/O THE CORRESP","",/ /,"",""
From File B.csv
"User","Sal","First","Last","Attn","Country",/ /,"Ffapplied_","Group"
From File C.csv
"User","Sal","First","Last","Attn","Country",/ /,"Ffapplied_","Group"
"CCD","","","Old HOUSING","","",/ /,"",""
From File D.csv
"User","Sal","First","Last","Attn","Country",/ /,"Ffapplied_","Group"
"CCD","","BOB","JONES","","",/ /,"",""
"CCD","MRS","","MAXWELL","","",/ /,"",""
So far I have the first line deleted from the four source files and can add the extra text above each header. Where I'm stuck is with file manipulation and selecting the blocks of text to be extracted. I can select CCD as my desired search text and destination filename. How do I select all the lines in a file that start with "CCD" (CCD may exist anywhere else in the line but only if it start with CCD should it be copied. All lines starting with "CCD" are together in a file.)?
I plan to open A.csv and run the macro. It will open B.csv, C.csv, & D.csv. End results the four initial files will be empty and I'll have created CCD.csv, Evan.csv, Halls.csv, Richard Bob.csv, and Richardson.csv. Other than using PreviousDocument and NextDocument is there a better way to manipulate the files?
Thanks in advance!!
"User","Sal","First","Last","Attn","Country",/ /,"Ffapplied_","Group"
"CCD","","","NEW HOUSING","","",/ /,"",""
"CCD","","BOB & JANE","SMITH","","",/ /,"",""
"CCD","","","CAMBRIA HEIGHTS","C/O THE CORRESP","",/ /,"",""
"Evan","","BILL & PAT","ALEX","","",/ /,"",""
"Evan","","RICHARD & BARBARA","ANDERSON","","",/ /,"",""
"Halls","","SANDY","CRICKET","","",/ /,"",""
"Halls","MRS","FERN","MAXWELL","TAZOR HILLS","",/ /,"",""
"Halls","","HOWARD & GLADYS","TESLA","","",/ /,"",""
"Richard Bob","","","1040 WINDOW INC","","",/ /,"","no email"
"Richard Bob","","","CHAPEL UMC","","",/ /,"",""
"Richardson","","SCOTT & CAROL","BASSEL","","",/ /,"","email"
"Richardson","","","BEACON COMMUNITY CHURCH","","",/ /,"",""
"Richardson","","","FIRST STREET PLUMBING","C/O MR ROBERTS","",/ /,"",""
The above list is from file A.csv which has all 5 instances that will be in the output files to be created (CCD.csv, Evan.csv, etc). The other three files will NOT have all instances, i.e. B.csv will only have Evan and Richardson. All files are sorted by the first field "user" with the exception of the header in line one, which is present in all files.
The resultant files will look like: filename = CCD.csv
From File A.csv
"User","Sal","First","Last","Attn","Country",/ /,"Ffapplied_","Group"
"CCD","","","NEW HOUSING","","",/ /,"",""
"CCD","","BOB & JANE","SMITH","","",/ /,"",""
"CCD","","","CAMBRIA HEIGHTS","C/O THE CORRESP","",/ /,"",""
From File B.csv
"User","Sal","First","Last","Attn","Country",/ /,"Ffapplied_","Group"
From File C.csv
"User","Sal","First","Last","Attn","Country",/ /,"Ffapplied_","Group"
"CCD","","","Old HOUSING","","",/ /,"",""
From File D.csv
"User","Sal","First","Last","Attn","Country",/ /,"Ffapplied_","Group"
"CCD","","BOB","JONES","","",/ /,"",""
"CCD","MRS","","MAXWELL","","",/ /,"",""
So far I have the first line deleted from the four source files and can add the extra text above each header. Where I'm stuck is with file manipulation and selecting the blocks of text to be extracted. I can select CCD as my desired search text and destination filename. How do I select all the lines in a file that start with "CCD" (CCD may exist anywhere else in the line but only if it start with CCD should it be copied. All lines starting with "CCD" are together in a file.)?
I plan to open A.csv and run the macro. It will open B.csv, C.csv, & D.csv. End results the four initial files will be empty and I'll have created CCD.csv, Evan.csv, Halls.csv, Richard Bob.csv, and Richardson.csv. Other than using PreviousDocument and NextDocument is there a better way to manipulate the files?
Thanks in advance!!