I need to be able to write the dataset below to a text file
"schHwy","TRIPID","SEQUENCE"
0,"1834556",24
0,"1834556",3
0,"1834556",4
0,"1834556",5
0,"1834556",6
0,"1834556",7
0,"1834556",8
0,"1834556",9
0,"1834847",1
0,"1834847",10
0,"1834847",11
0,"1834847",12
0,"1834847",13
0,"1834847",14
I need a VBA macro to write the dataset above to a text file in the format below
where case = "TRIPID"
{Command.seq_num} in "SEQUENCE"
then "schHwy"
Case '1833863':
If {Command.seq_num} in [1] then
8
Else
If {Command.seq_num} in [2] then
10
Else
If {Command.seq_num} in [3,4] then
11
Else
If {Command.seq_num} in [5,6] then
12
Else
If {Command.seq_num} in [7] then
13
Else
If {Command.seq_num} in [8] then
14
Else
If {Command.seq_num} in [9,10,11,12,13,14,15,16] then
15
Else
If {Command.seq_num} in [17,18] then
16
Else
If {Command.seq_num} in [19] then
17
Else
If {Command.seq_num} in [20,21,22] then
18
Else
20
Case '1833875':
If {Command.seq_num} in [1] then
14
Else
If {Command.seq_num} in [2,3,4] then
13
Else
If {Command.seq_num} in [5,6] then
12
Else
If {Command.seq_num} in [7,8] then
11
Else
If {Command.seq_num} in [9,10,11,12,13,14,15,16,17,18] then
10
Else
9
Case '1833878':
If {Command.seq_num} in [1,2,18] then
11
Else
If {Command.seq_num} in [3,4,5,6,7,8,9,10,11,12,13,14,15,16,17] then
10
Else
12
Case '1833881':
If {Command.seq_num} in [1,2,3,4] then
9
Else
If {Command.seq_num} in [5,6,7,8,9,10,11,12,13] then
10
Else
If {Command.seq_num} in [14,15,16,17,18] then
11
Else
If {Command.seq_num} in [19] then
12
Else
If {Command.seq_num} in [20,21] then
13
Else
14
Case '1833913':
If {Command.seq_num} in [1,2,3,4,5,6] then
9
Else
If {Command.seq_num} in [7,8,9,10,11,12] then
10
Else
If {Command.seq_num} in [13,14] then
11
Else
If {Command.seq_num} in [15] then
13
Else
If {Command.seq_num} in [16] then
14
Else
If {Command.seq_num} in [17] then
16
Else
If {Command.seq_num} in [18,19] then
17
Else
If {Command.seq_num} in [20,21] then
19
Else
If {Command.seq_num} in [22] then
20
Else
21
"schHwy","TRIPID","SEQUENCE"
0,"1834556",24
0,"1834556",3
0,"1834556",4
0,"1834556",5
0,"1834556",6
0,"1834556",7
0,"1834556",8
0,"1834556",9
0,"1834847",1
0,"1834847",10
0,"1834847",11
0,"1834847",12
0,"1834847",13
0,"1834847",14
I need a VBA macro to write the dataset above to a text file in the format below
where case = "TRIPID"
{Command.seq_num} in "SEQUENCE"
then "schHwy"
Case '1833863':
If {Command.seq_num} in [1] then
8
Else
If {Command.seq_num} in [2] then
10
Else
If {Command.seq_num} in [3,4] then
11
Else
If {Command.seq_num} in [5,6] then
12
Else
If {Command.seq_num} in [7] then
13
Else
If {Command.seq_num} in [8] then
14
Else
If {Command.seq_num} in [9,10,11,12,13,14,15,16] then
15
Else
If {Command.seq_num} in [17,18] then
16
Else
If {Command.seq_num} in [19] then
17
Else
If {Command.seq_num} in [20,21,22] then
18
Else
20
Case '1833875':
If {Command.seq_num} in [1] then
14
Else
If {Command.seq_num} in [2,3,4] then
13
Else
If {Command.seq_num} in [5,6] then
12
Else
If {Command.seq_num} in [7,8] then
11
Else
If {Command.seq_num} in [9,10,11,12,13,14,15,16,17,18] then
10
Else
9
Case '1833878':
If {Command.seq_num} in [1,2,18] then
11
Else
If {Command.seq_num} in [3,4,5,6,7,8,9,10,11,12,13,14,15,16,17] then
10
Else
12
Case '1833881':
If {Command.seq_num} in [1,2,3,4] then
9
Else
If {Command.seq_num} in [5,6,7,8,9,10,11,12,13] then
10
Else
If {Command.seq_num} in [14,15,16,17,18] then
11
Else
If {Command.seq_num} in [19] then
12
Else
If {Command.seq_num} in [20,21] then
13
Else
14
Case '1833913':
If {Command.seq_num} in [1,2,3,4,5,6] then
9
Else
If {Command.seq_num} in [7,8,9,10,11,12] then
10
Else
If {Command.seq_num} in [13,14] then
11
Else
If {Command.seq_num} in [15] then
13
Else
If {Command.seq_num} in [16] then
14
Else
If {Command.seq_num} in [17] then
16
Else
If {Command.seq_num} in [18,19] then
17
Else
If {Command.seq_num} in [20,21] then
19
Else
If {Command.seq_num} in [22] then
20
Else
21