Results 1 to 2 of 2

Need Help in importing data from series of data from notepad

Threaded View

  1. #1
    Registered User
    Join Date
    09-02-2012
    Location
    Kathmandu, Nepal
    MS-Off Ver
    Excel 2003
    Posts
    1

    Need Help in importing data from series of data from notepad

    Dear Users,
    I am currently using Excel 2003 and I am trying to import 15 years of temperature data (each stored in separate notepads) into excel and then stack it into three columns (viz. Date, Min temp., Max. temp) . I managed to import the data as "Single" while defining the array. However I later found out that the data contained numeric values as well as some missing values denoted as 'DNA'(Data not available) and 'T'. When i used the "SIngle" definition to the array, excel imported DNA as '0'. Is there any shortened idea to import all the data from the notepad as they were? I have attached a sample data herewith. I need to open 15 years of the data. This is the code i used:

    Sub readnwritedata()
    '   Add number daily data as sheets in excel
        Dim A(1 To 370, 1 To 5) As Single
        Dim Inoofsimulationdays As Integer, l As Integer, Year As Integer
        Open "C:\Users\Dhiraj\Desktop\Koshi Basin Hydrology and Meteorology Data\All temperature Stations\Station 1024\TA102419.95" For Input As #1
        Open "C:\Users\Dhiraj\Desktop\Koshi Basin Hydrology and Meteorology Data\All temperature Stations\Station 1024\TA102419.96" For Input As #2
        Open "C:\Users\Dhiraj\Desktop\Koshi Basin Hydrology and Meteorology Data\All temperature Stations\Station 1024\TA102419.97" For Input As #3
        Open "C:\Users\Dhiraj\Desktop\Koshi Basin Hydrology and Meteorology Data\All temperature Stations\Station 1024\TA102419.98" For Input As #4
        Open "C:\Users\Dhiraj\Desktop\Koshi Basin Hydrology and Meteorology Data\All temperature Stations\Station 1024\TA102419.99" For Input As #5
        Open "C:\Users\Dhiraj\Desktop\Koshi Basin Hydrology and Meteorology Data\All temperature Stations\Station 1024\TA102420.00" For Input As #6
        Open "C:\Users\Dhiraj\Desktop\Koshi Basin Hydrology and Meteorology Data\All temperature Stations\Station 1024\TA102420.01" For Input As #7
        Open "C:\Users\Dhiraj\Desktop\Koshi Basin Hydrology and Meteorology Data\All temperature Stations\Station 1024\TA102420.02" For Input As #8
        Open "C:\Users\Dhiraj\Desktop\Koshi Basin Hydrology and Meteorology Data\All temperature Stations\Station 1024\TA102420.03" For Input As #9
        Open "C:\Users\Dhiraj\Desktop\Koshi Basin Hydrology and Meteorology Data\All temperature Stations\Station 1024\TA102420.04" For Input As #10
        Open "C:\Users\Dhiraj\Desktop\Koshi Basin Hydrology and Meteorology Data\All temperature Stations\Station 1024\TA102420.05" For Input As #11
        Open "C:\Users\Dhiraj\Desktop\Koshi Basin Hydrology and Meteorology Data\All temperature Stations\Station 1024\TA102420.06" For Input As #12
        Open "C:\Users\Dhiraj\Desktop\Koshi Basin Hydrology and Meteorology Data\All temperature Stations\Station 1024\TA102420.07" For Input As #13
        Open "C:\Users\Dhiraj\Desktop\Koshi Basin Hydrology and Meteorology Data\All temperature Stations\Station 1024\TA102420.08" For Input As #14
        Open "C:\Users\Dhiraj\Desktop\Koshi Basin Hydrology and Meteorology Data\All temperature Stations\Station 1024\TA102420.09" For Input As #15
        Inoofsimulationdays = 15
        
        For k = 1 To Inoofsimulationdays
            Sheets.Add Type:=xlWorksheet, Count:=1
            Year = 1994 + k
            ActiveSheet.Name = Year
        If (Year Mod 4) = 0 Then l = 366 Else l = 365
        
        For i = 1 To l
            For j = 1 To 3
            Input #k, A(i, j)
            Next j
        Next i
        For i = 1 To l
            For j = 1 To 3
            ActiveSheet.Cells(i, j).Value = A(i, j)
            Next j
        Next i
        EOF k
        Close #k
        Next k
    End Sub
    Attached Files Attached Files
    Last edited by Cutter; 09-02-2012 at 09:29 AM. Reason: Added code tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1