Results 1 to 3 of 3

VBA macro to re-format data

Threaded View

mturbin VBA macro to re-format data 05-19-2009, 04:53 AM
royUK Re: VBA macro to re-format... 05-19-2009, 05:00 AM
mturbin Re: VBA macro to re-format... 05-19-2009, 06:50 AM
  1. #1
    Registered User
    Join Date
    05-19-2009
    Location
    Hitchin, England
    MS-Off Ver
    Excel 2003
    Posts
    2

    VBA macro to re-format data

    Hi all,

    A simple VBA question.

    I am using (or trying to) an excel macro to read temperatures from a file and output them in a new formatted file. The macro is;
    Sub test1()
    '
    ' Format Temperature File
    '
    FileName1 = "D:\data\temps.inp"
    
    Open FileName1 For Input As #1
    Open "D:\data\temps.out" For Output As #3
    
    ' Read File reformat and output
    
    Do While Not EOF(1)
        Line Input #1, Dummy1
          Point1 = Left(Dummy1, 8)
          Temp1 = Mid(Dummy1, 10, 21)
          Print #3,    Val(Temp1)
          Print #3, Point1
    Loop
    
    Close #1
    Close #3
    
    End Sub
    I want;

    ^^^970.031
    3000001
    ^^^934.616
    3000002
    ^^^882.253
    3000003
    ^^^560.491
    3000004
    ^^^575.562
    3000005

    I get;

    970.031
    3000001
    934.616
    3000002
    882.253
    3000003
    560.491
    3000004
    575.562
    3000005

    How do I modify the macro to give me what I require.

    ie 3 spaces, temperature
    0 spaces, point

    Thanks for reading. All help gratefully received.

    M
    Last edited by royUK; 05-19-2009 at 05:00 AM.

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