VBA Code Needed to Reorganize Dated Columnar Data to Sequenced Row Data

powerjak

New Member
Joined
Jan 28, 2003
Messages
29
Raw data is Comma Delimited text file organized Column-wise. For each daily date (oldest to newest), there are various weather data in adjacent Columns. I am only interested in two Columns of data ... the MAX & MIN Temp for each day. I need to process the data and reorganize it Row-wise. One Row for each Month, with the Temps Rounded to nearest Whole Number, then sequenced MAX, then MIN, for each day of the Month. Each Row only contains MAX & MIN values for as many days as there are in a Month, (not 'padded') to 31 days. Some of the Temps in the Source file may include an asterisk at the end of the value (indicates value that is based on fewer than 24 hourly samples). The asterisk must be stripped off during the processing and sequencing. I have to enter/insert the appropriate Weather Station Identifier (Max of 4-digit Text) for the WBAN value in Column 2, and the Weather Station Name for the Station Identifier (Max of 20-Character Text). Text values must be enclosed in double-quotes. After processing, the data needs to be Saved/Exported as a Comma Delimited ASCII text file.

Example of Source Comma Delimited, Columnarized Data:
STN---,WBAN , YEARMODA, TEMP, , DEWP, , SLP , , STP , , VISIB, , WDSP, , MXSPD, GUST, MAX , MIN ,PRCP ,SNDP , FRSHTT,
430630,99999, 20040101, 67.9, 8, 51.4, 8, 1015.3, 8, 952.0, 8, 3.9, 8, 0.2, 8, 1.0, 999.9, 88.0 , 52.5 , 0.00D,999.9, 000000,
430630,99999, 20040102, 65.1, 7, 51.9, 7, 1014.9, 7, 951.4, 7, 3.6, 7, 0.3, 7, 1.0, 999.9, 88.7 , 50.7 , 0.00D,999.9, 000000,
430630,99999, 20040103, 69.4, 6, 52.0, 6, 1014.5, 6, 951.5, 6, 4.3, 6, 0.3, 6, 1.0, 999.9, 87.3 , 51.1 , 0.00D,999.9, 000000,
430630,99999, 20040104, 68.2, 8, 52.4, 8, 1014.5, 8, 951.3, 8, 3.9, 8, 0.8, 8, 4.1, 999.9, 87.8 , 51.6 , 0.00D,999.9, 000000,
430630,99999, 20040105, 68.9, 8, 52.7, 8, 1014.3, 8, 951.2, 8, 3.9, 8, 0.2, 8, 1.9, 999.9, 85.8 , 52.9 , 0.00D,999.9, 000000,
430630,99999, 20040106, 68.3, 8, 52.8, 8, 1014.1, 8, 951.2, 8, 3.9, 8, 0.5, 8, 1.9, 999.9, 86.4 , 51.1 , 0.00D,999.9, 000000,
430630,99999, 20040107, 68.7, 7, 56.8, 7, 1015.2, 7, 952.1, 7, 4.1, 7, 2.1, 7, 8.0, 999.9, 81.1 , 55.4*, 0.00E,999.9, 010000,
430630,99999, 20040108, 67.1, 8, 54.3, 8, 1017.4, 8, 954.0, 8, 3.9, 8, 1.1, 8, 5.1, 999.9, 82.6 , 54.3*, 0.00G,999.9, 000000,
430630,99999, 20040109, 65.2, 8, 49.5, 8, 1017.7, 8, 954.1, 8, 3.9, 8, 1.2, 8, 6.0, 999.9, 81.5 , 50.7*, 0.00D,999.9, 000000,
430630,99999, 20040110, 64.5, 8, 49.3, 8, 1017.5, 8, 953.8, 8, 3.9, 8, 0.9, 8, 4.1, 999.9, 82.4 , 48.4*, 0.00D,999.9, 000000,
430630,99999, 20040111, 64.6, 8, 47.8, 8, 1016.3, 8, 952.8, 8, 3.9, 8, 0.8, 8, 2.9, 999.9, 84.2 , 48.4*, 0.00D,999.9, 000000,
430630,99999, 20040112, 65.4, 7, 47.5, 7, 1015.8, 7, 952.3, 7, 3.6, 7, 1.9, 7, 8.9, 999.9, 84.7 , 46.8*, 0.00D,999.9, 000000,
430630,99999, 20040113, 66.7, 8, 49.8, 8, 1013.7, 8, 950.6, 8, 3.9, 8, 0.4, 8, 1.9, 999.9, 89.4 , 47.7*, 0.00D,999.9, 000000,
430630,99999, 20040114, 68.0, 8, 48.2, 8, 1012.5, 8, 949.5, 8, 3.9, 8, 1.0, 8, 2.9, 999.9, 90.9 , 48.9*, 0.00D,999.9, 000000,
430630,99999, 20040115, 69.2, 8, 50.0, 8, 1013.3, 8, 950.3, 8, 3.9, 8, 0.5, 8, 2.9, 999.9, 92.1 , 48.9*, 0.00G,999.9, 000000,
430630,99999, 20040116, 70.9, 8, 52.2, 8, 1013.5, 8, 950.7, 8, 3.9, 8, 0.6, 8, 2.9, 999.9, 91.8 , 51.1*, 0.00D,999.9, 000000,
430630,99999, 20040117, 72.2, 8, 54.8, 8, 1012.0, 8, 948.9, 8, 3.9, 8, 1.1, 8, 4.1, 999.9, 91.4 , 54.5*, 0.00D,999.9, 000000,
430630,99999, 20040118, 71.2, 8, 53.1, 8, 1012.2, 8, 949.5, 7, 3.9, 8, 0.5, 8, 2.9, 999.9, 90.5 , 55.8*, 0.00D,999.9, 000000,
430630,99999, 20040119, 72.5, 7, 50.6, 7, 1010.5, 7, 947.7, 7, 3.6, 7, 1.4, 7, 5.1, 999.9, 91.0 , 56.1*, 0.00D,999.9, 000000,
430630,99999, 20040120, 72.5, 8, 53.2, 8, 1009.8, 8, 947.4, 8, 3.9, 8, 1.1, 8, 2.9, 999.9, 90.7 , 54.0*, 0.00D,999.9, 000000,
430630,99999, 20040121, 69.3, 7, 57.8, 7, 1009.4, 7, 945.4, 7, 3.6, 7, 1.0, 7, 2.9, 999.9, 83.1 , 59.7*, 0.00D,999.9, 000000,
430630,99999, 20040122, 70.2, 6, 58.0, 6, 1010.1, 6, 947.5, 6, 4.3, 6, 2.3, 6, 8.0, 999.9, 82.6 , 58.8*, 0.00D,999.9, 000000,
430630,99999, 20040123, 68.1, 8, 50.5, 8, 1011.4, 8, 948.5, 8, 3.9, 8, 2.1, 8, 4.1, 999.9, 81.5 , 54.7*, 0.00D,999.9, 000000,
430630,99999, 20040124, 65.7, 8, 49.8, 8, 1012.1, 8, 948.9, 8, 3.9, 8, 1.4, 8, 5.1, 999.9, 82.4 , 48.4*, 0.00D,999.9, 000000,
430630,99999, 20040125, 68.0, 8, 54.3, 8, 1011.3, 8, 948.4, 8, 3.9, 8, 1.1, 8, 2.9, 999.9, 86.2 , 52.0*, 0.00D,999.9, 000000,
430630,99999, 20040126, 68.2, 8, 51.6, 8, 1011.8, 8, 948.9, 8, 3.9, 8, 1.4, 8, 4.1, 999.9, 85.8 , 52.7*, 0.00D,999.9, 000000,
430630,99999, 20040127, 67.4, 8, 56.0, 8, 1011.4, 8, 948.4, 8, 3.9, 8, 1.4, 8, 6.0, 999.9, 82.4 , 52.0*, 0.00D,999.9, 000000,
430630,99999, 20040128, 72.5, 8, 57.4, 8, 1009.5, 8, 947.2, 8, 3.9, 8, 1.3, 8, 2.9, 999.9, 88.0 , 57.7*, 0.00D,999.9, 000000,
430630,99999, 20040129, 72.2, 8, 58.5, 8, 1009.8, 8, 947.4, 8, 3.9, 8, 1.6, 8, 2.9, 999.9, 87.4*, 59.0*, 0.00D,999.9, 000000,
430630,99999, 20040130, 70.5, 8, 59.6, 8, 1011.2, 8, 948.5, 8, 3.9, 8, 1.9, 8, 6.0, 999.9, 84.0*, 59.2*, 0.00D,999.9, 000000,
430630,99999, 20040131, 67.7, 7, 53.9, 7, 1011.9, 7, 948.3, 7, 4.1, 7, 2.1, 7, 8.0, 999.9, 81.0*, 54.7*, 0.00D,999.9, 000000,
430630,99999, 20040201, 67.2, 8, 44.9, 8, 1011.4, 8, 948.3, 8, 3.9, 8, 0.6, 8, 2.9, 999.9, 82.6*, 49.8*, 0.00D,999.9, 000000,
430630,99999, 20040202, 68.0, 8, 53.4, 8, 1012.5, 8, 949.5, 8, 3.9, 8, 0.9, 8, 5.1, 999.9, 82.9*, 51.8*, 0.00D,999.9, 000000,
430630,99999, 20040203, 72.5, 8, 59.1, 8, 1012.4, 8, 949.9, 8, 3.9, 8, 1.0, 8, 4.1, 999.9, 86.7*, 56.1*, 0.00D,999.9, 000000,
430630,99999, 20040204, 73.4, 8, 59.0, 8, 1011.1, 8, 948.3, 8, 3.4, 8, 2.3, 8, 6.0, 999.9, 89.6*, 58.8*, 0.00D,999.9, 000000,
430630,99999, 20040205, 72.2, 7, 46.4, 7, 1012.4, 7, 949.8, 7, 4.1, 7, 1.2, 7, 2.9, 999.9, 88.0*, 52.5*, 0.00D,999.9, 000000,
430630,99999, 20040206, 66.4, 8, 38.5, 6, 1014.6, 7, 951.1, 7, 3.9, 8, 0.7, 8, 2.9, 999.9, 87.1*, 45.1*, 0.00D,999.9, 000000,
430630,99999, 20040207, 66.7, 8, 41.2, 8, 1016.8, 8, 953.3, 8, 3.9, 8, 0.6, 8, 2.9, 999.9, 88.3*, 46.8*, 0.00D,999.9, 000000,
430630,99999, 20040208, 69.5, 7, 43.3, 7, 1016.2, 7, 953.1, 7, 4.1, 7, 1.1, 7, 2.9, 999.9, 88.3*, 47.3*, 0.00D,999.9, 000000,
430630,99999, 20040209, 71.2, 8, 48.4, 8, 1014.1, 8, 951.3, 8, 3.9, 8, 0.5, 8, 1.9, 999.9, 91.4*, 50.2*, 0.00G,999.9, 000000,
430630,99999, 20040210, 71.6, 8, 48.7, 8, 1014.2, 8, 951.4, 8, 3.9, 8, 1.0, 8, 2.9, 999.9, 92.5*, 52.7*, 0.00D,999.9, 000000,
430630,99999, 20040211, 71.6, 8, 47.3, 8, 1014.4, 8, 951.6, 8, 3.9, 8, 1.2, 8, 4.1, 999.9, 92.1*, 51.4*, 0.00G,999.9, 000000,
430630,99999, 20040212, 72.9, 8, 51.1, 8, 1014.1, 8, 951.5, 8, 3.4, 8, 0.7, 8, 1.9, 999.9, 92.3*, 54.3*, 0.00D,999.9, 000000,
430630,99999, 20040213, 75.1, 8, 52.4, 8, 1013.3, 7, 951.2, 8, 3.9, 8, 0.7, 8, 2.9, 999.9, 93.0*, 54.9*, 0.00G,999.9, 000000,
430630,99999, 20040214, 74.4, 8, 52.8, 8, 1013.0, 8, 950.6, 8, 3.9, 8, 0.4, 8, 1.0, 999.9, 92.3*, 57.9*, 0.00D,999.9, 000000,
430630,99999, 20040215, 75.2, 8, 53.7, 8, 1012.5, 8, 950.3, 8, 3.9, 8, 0.6, 8, 1.9, 999.9, 91.6*, 58.1*, 0.00D,999.9, 000000,
430630,99999, 20040216, 74.0, 8, 53.3, 8, 1013.0, 8, 950.7, 8, 3.9, 8, 0.6, 8, 1.9, 999.9, 91.4*, 57.2*, 0.00G,999.9, 000000,
430630,99999, 20040217, 75.9, 7, 52.8, 7, 1011.2, 7, 949.2, 7, 4.1, 7, 0.4, 7, 1.0, 999.9, 93.4*, 56.7*, 0.00D,999.9, 000000,
430630,99999, 20040218, 74.6, 8, 52.1, 8, 1009.6, 8, 947.4, 8, 3.9, 8, 0.6, 8, 1.9, 999.9, 93.2*, 56.5*, 0.00G,999.9, 000000,
430630,99999, 20040219, 72.6, 8, 51.0, 8, 1010.6, 8, 948.4, 7, 3.9, 8, 2.2, 8, 8.0, 999.9, 90.0*, 55.4*, 0.00D,999.9, 000000,
430630,99999, 20040220, 76.0, 7, 51.4, 7, 1011.7, 7, 949.7, 7, 4.1, 7, 0.7, 7, 1.9, 999.9, 95.0*, 53.2*, 0.00D,999.9, 000000,
430630,99999, 20040221, 77.8, 8, 51.5, 8, 1012.7, 8, 950.8, 8, 3.9, 8, 1.0, 8, 1.9, 999.9, 96.4*, 57.6*, 0.00D,999.9, 000000,
430630,99999, 20040222, 76.2, 8, 50.8, 8, 1012.1, 8, 950.0, 8, 3.9, 8, 0.7, 8, 2.9, 999.9, 95.7*, 58.6*, 0.00D,999.9, 000000,
430630,99999, 20040223, 77.2, 8, 49.2, 8, 1011.8, 8, 949.8, 8, 4.3, 8, 0.5, 8, 2.9, 999.9, 96.6*, 57.6*, 0.00D,999.9, 000000,
430630,99999, 20040224, 77.7, 8, 47.7, 8, 1012.6, 8, 950.7, 8, 3.9, 8, 0.5, 8, 1.9, 999.9, 98.2*, 55.4*, 0.00D,999.9, 000000,
430630,99999, 20040225, 79.2, 7, 48.3, 7, 1012.0, 7, 950.3, 7, 4.1, 7, 0.7, 7, 1.9, 999.9, 97.7*, 57.6*, 0.00D,999.9, 000000,
430630,99999, 20040226, 78.5, 8, 49.7, 8, 1010.0, 8, 948.3, 8, 3.9, 8, 0.2, 8, 1.0, 999.9, 97.3*, 57.7*, 0.00D,999.9, 000000,
430630,99999, 20040227, 77.8, 8, 49.2, 8, 1009.8, 8, 948.1, 8, 3.9, 8, 1.0, 8, 5.1, 999.9, 96.3*, 59.4*, 0.00G,999.9, 000000,
430630,99999, 20040228, 76.3, 8, 50.9, 8, 1010.5, 8, 948.5, 8, 3.9, 8, 2.4, 8, 8.0, 999.9, 95.0*, 58.1*, 0.00D,999.9, 000000,
430630,99999, 20040229, 77.3, 8, 53.1, 8, 1011.0, 8, 949.1, 8, 3.9, 8, 0.6, 8, 1.9, 999.9, 96.6*, 58.1*, 0.00G,999.9, 000000,

Example of Desired Result Comma Delimited, Row-wise Data:
"99999","PUNE","Pune,India",2004,01,88,53,89,51,87,51,88,52,86,53,86,51,81,55,83,54,82,51,82,48,84,48,85,47,89,48,91,49,92,49,92,51,91,55,91,56,91,56,91,54,83,60,83,59,82,55,82,48,86,52,86,53,82,52,88,58,87,59,84,59,81,55
"99999","PUNE","Pune,India",2004,02,83,50,83,52,87,56,90,59,88,53,87,45,88,47,88,47,91,50,93,53,92,51,92,54,93,55,92,58,92,58,91,57,93,57,93,57,90,55,95,53,96,58,96,59,97,58,98,55,98,58,97,58,96,59,95,58,97,58,,,,

I hope someone can help me! Thanks in advance.
powerjak
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,214,911
Messages
6,122,192
Members
449,072
Latest member
DW Draft

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