sas

sas

  • NA
  • 1
  • 3.7k

Compare 2 excel spreadsheets in vb

Feb 21 2011 3:35 PM
I have a reporting tool that outputs an intermediate excel file. The report has say maximum 20 header columns and 60 rows. If in all 60 rows there is no data for column 15 & 19, those columns are not printed in the excel report, hence the report ends up with 18 columns. I am trying to have a VB code that can compare 2 excel files; 1 with all the 20 column headers in the header row - FILE A as a standard file and the other file will be the output report that has a dynamic header row based on actual output -FILE B - and it should save whatever columns that are missing to a text file or if possible create a third excel file -FILE C- that is a copy of FILE B and appends to it the columns that are missing from FILE A and add zeros (0) to all the rows of the missing columns. This way I can have a uniform standard output file that will always have header row with all 20 columns. Any help will be appreaciated! I am new to VB programming :) Thank you all in advance!

EG. FILE A

First Name        Last Name        Age        D.O.B        Place        School        Year of Grad        Stat




FILE B (missing Stat column becoz no data exist for all rows)
First Name        Last Name        Age        D.O.B        Place        School        Year of Grad      
XYZ                ABC                10          2/2/2011    STA        PQA                1995                
XYZ                ABC                10          2/2/2011    STA        PQA                1995                
XYZ                ABC                10          2/2/2011    STA        PQA                1995                

Solution - FILE C 
First Name        Last Name        Age        D.O.B        Place        School        Year of Grad      Stat
XYZ                ABC                10          2/2/2011    STA        PQA                1994                0
QWE               ABC                10          2/2/2011    STA        PQA                1998                0
SDF                ABC                10          2/2/2011    STA        PQA                1999                0

Answers (1)