Hi All,
We need your help in creating a macro to achieve the below output. We have an excel file(Rawdata.xls) which contains data as:
C1 C2 C3 C4 C5 C6 C7
12345 20 24/12/2007 07/03/2008 C 19/11/2008 19/11/2008
124 10 4/12/2007 P 4/12/2007
143 5 1/1/2006 07/03/200 A 07/03/2008
C7 is the last update date.
What we require is this data to be split into another excel file(Split.xls) based on the logic that:
For C5 if the value is P there should be one insert, with the value of C1,C2,C3 and C5 .
if the value is A there will be two inserts one for C5 = P, C1,C2,C3 and C5 . and the other for C7 = A. C1,C2,C3,C4 and C5 . and
if the value is C there will be three inserts one for C7 = P ,the other for C7 = A. and finally C7=C .
Basically if
C5 =P consider C3...C4 and C6 will be null.
C5 =A consider C3and C4 .C6 will be null.
C5 =C consider all dates but C4 can be null.
So the final output for the above three records would be:
Case 1:
C1 C2 C3 C4 C5 C6 C7
12345 20 24/12/2007 Null P NULL 24/12/2007
12345 20 24/12/2007 07/03/2008 A NULL 07/03/2008
12345 20 24/12/2007 07/03/2008 C 19/11/2008 19/11/2008
Case 2:
C1 C2 C3 C4 C5 C6 C7
124 10 4/12/2007 Null P Null 4/12/2007
Case 3:
C1 C2 C3 C4 C5 C6 C7
143 5 1/1/2006 Null P Null 1/1/2006
143 5 1/1/2006 07/03/2008 A Null 7/03/2008
Thanks for any help.
The sample scenario file has been uploaded.
Bookmarks