+ Reply to Thread
Results 1 to 2 of 2

Reading a file as formated in the sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    04-04-2013
    Location
    San Jose, CA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Question Reading a file as formated in the sheet

    Hello everyone,
    This is my first post, so please accept my appologies if I have intruded any rules in my post.

    So, I have created an excel file which has 11 tabs which some of them are connected to each other in terms of calculations.
    The task for each one is to provide me with a text file output which is in a specific format which is later going to be an input to a very complicated FORTRAN code.

    Right now I have 12 macros which almost does the job but there is one problem here,
    I have formated some of my cells to have, say 3 decimal places and some with 6. But when the code reads it in order to make a text file out of that specific cell, It reads e.g. 1.000 as 1 and saves it in the file. How do I implement that in my macro code.
    Sorry if the description was long. I wanted it to be complete. I cannot post my data since its confidential, but a part of my code that creates the file can be seen below:

    oTSStream.Write rngeRangeToWrite.Cells(5, 4) & vbCrLf & strDashline & vbCrLf & Cells(7, 4) & vbCrLf

    If Range("D7") = 1 Then
    oTSStream.Write rngeRangeToWrite.Cells(8, 4) & strDelimiter & Cells(9, 4) & vbCrLf & strDashline & vbCrLf
    End If

    Best Regards,

  2. #2
    Registered User
    Join Date
    04-04-2013
    Location
    San Jose, CA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Reading a file as formated in the sheet

    I found the way of overcomming the problem.
    If anyone else has the same problem the solution was very easy.
    Instead of using Cells(x,y) I had to use Cells(x,y).Text
    This forces excel to use the displayed value instead of the actual format inside it.

+ Reply to Thread

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