+ Reply to Thread
Results 1 to 11 of 11

Export/import between Excel and textfile

Hybrid View

Axmed.cm Export/import between Excel... 01-08-2017, 08:34 AM
Richard Buttrey Re: Export/import between... 01-08-2017, 11:29 AM
Axmed.cm Re: Export/import between... 01-08-2017, 12:46 PM
Logit Re: Export/import between... 01-08-2017, 02:51 PM
Logit Re: Export/import between... 01-09-2017, 07:44 PM
Axmed.cm Re: Export/import between... 01-09-2017, 11:42 PM
Axmed.cm Re: Export/import between... 01-12-2017, 04:41 AM
YasserKhalil Re: Export/import between... 01-13-2017, 01:56 AM
Axmed.cm Re: Export/import between... 01-13-2017, 01:46 PM
Axmed.cm Re: Export/import between... 01-13-2017, 02:13 PM
YasserKhalil Re: Export/import between... 01-13-2017, 05:38 PM
  1. #1
    Forum Contributor Axmed.cm's Avatar
    Join Date
    02-05-2015
    Location
    Somalia
    MS-Off Ver
    2013
    Posts
    231

    Export/import between Excel and textfile

    Hi All


    Could someone help me import/export the attached excel file to/from text file

    I just want the maarks to be exported/imported
    Thank you in advance
    Ahmedee
    Attached Files Attached Files
    GUURE

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Export/import between Excel and textfile

    You need to be clearer and tell us exactly what a .txt output file should look like.
    Do you literally mean a .txt or perhaps a csv?
    I presume, but you don't say, that you want names as well as marks?
    Do you want Total Marks?

    When you say you want to import a file what does the file you want to import look like. Please upload.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor Axmed.cm's Avatar
    Join Date
    02-05-2015
    Location
    Somalia
    MS-Off Ver
    2013
    Posts
    231

    Re: Export/import between Excel and textfile

    Thank you Richard for the reply.
    What I need is a way I can export non formulated data; names and marks (Not percentage and totals) to a textfile (.txt) and allows me to import it later.
    I dont care how the exported data looks like in the textfile.

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,444

    Re: Export/import between Excel and textfile

    .
    .
    Here is a project you can use. Everything is there, you just have to alter the range values to match your existing data orientation.
    It includes two different methods of 'reading and writing' a text file.
    Attached Files Attached Files

  5. #5
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,444

    Re: Export/import between Excel and textfile

    Thank you for the add rep.

    Please mark the thread as solved.

  6. #6
    Forum Contributor Axmed.cm's Avatar
    Join Date
    02-05-2015
    Location
    Somalia
    MS-Off Ver
    2013
    Posts
    231

    Re: Export/import between Excel and textfile

    Dear Logit.
    I am still unable to apply this in my sheet.
    May you please?

  7. #7
    Forum Contributor Axmed.cm's Avatar
    Join Date
    02-05-2015
    Location
    Somalia
    MS-Off Ver
    2013
    Posts
    231

    Re: Export/import between Excel and textfile

    Hello,
    Anyone would help me to do this?

  8. #8
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Export/import between Excel and textfile

    Try this
    Sub PrintAsString()
        Dim sLine           As String
        Dim sFName          As String
        Dim intFNumber      As Integer
        Dim lCounter        As Long
        Dim lLastRow        As Long
        Dim i               As Long
    
        lLastRow = 11
    
        sFName = ThisWorkbook.Path & "\Excel Data (Print).txt"
        intFNumber = FreeFile
        Open sFName For Output As #intFNumber
    
        For lCounter = 4 To lLastRow
            With Sheet1
                sLine = .Cells(lCounter, 2) & vbTab
                For i = 3 To 15
                    sLine = sLine & .Cells(lCounter, i) & vbTab
                Next i
            End With
    
            Print #intFNumber, sLine
        Next lCounter
    
        Close #intFNumber
        MsgBox "Values From Sheet '" & Sheet1.Name & "' Were Written To '" & sFName & "' File!", vbInformation
    End Sub
    Sub ReadStringData()
        Dim sLine           As String
        Dim sFName          As String
        Dim intFNumber      As Integer
        Dim lRow            As Long
        Dim lColumn         As Long
        Dim vDataValues     As Variant
        Dim intCount        As Integer
    
        sFName = ThisWorkbook.Path & "\Excel Data (Print).txt"
        intFNumber = FreeFile
    
        On Error Resume Next
            Open sFName For Input As #intFNumber
        
            If Err.Number <> 0 Then
                MsgBox "Text File Not Found!", vbCritical, "Error!"
                Exit Sub
            End If
        On Error GoTo 0
    
        lRow = 18
    
        Do While Not EOF(intFNumber)
            Line Input #intFNumber, sLine
            vDataValues = Split(sLine, vbTab)
    
            With Sheet1
                lColumn = 2
                For intCount = LBound(vDataValues) To UBound(vDataValues)
                    .Cells(lRow, lColumn) = vDataValues(intCount)
                    lColumn = lColumn + 1
                Next intCount
            End With
    
            lRow = lRow + 1
        Loop
    
        Close #intFNumber
    
        Range("A1").Select
        MsgBox "Values From File '" & sFName & "' Were Imported To Sheet '" & Sheet1.Name & "'!", vbInformation
    End Sub
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  9. #9
    Forum Contributor Axmed.cm's Avatar
    Join Date
    02-05-2015
    Location
    Somalia
    MS-Off Ver
    2013
    Posts
    231

    Re: Export/import between Excel and textfile

    شكرا جزيلا اخى العزيز
    طيب الله اوقاتك

  10. #10
    Forum Contributor Axmed.cm's Avatar
    Join Date
    02-05-2015
    Location
    Somalia
    MS-Off Ver
    2013
    Posts
    231

    Re: Export/import between Excel and textfile

    It is solved

  11. #11
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Export/import between Excel and textfile

    You're welcome. Glad I can offer some help
    Thanks for Logit as he has posted the original code

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. how can i import data from a textfile into excel 2007 ?
    By sumesh56 in forum Excel General
    Replies: 10
    Last Post: 10-10-2014, 10:57 AM
  2. Implementing TextFile import Delimiter settings on TXT Import VBA Script
    By Canuckle777 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-19-2013, 02:06 PM
  3. [SOLVED] Remove colon on textfile import !
    By Petter120 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-10-2012, 11:27 AM
  4. Import textfile to excel
    By Petter120 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2012, 05:13 PM
  5. [SOLVED] Import textfile to excel and split (spaces) to column !
    By Petter120 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-09-2012, 02:04 PM
  6. Import Textfile WITHOUT showing wizard..
    By Armitage2k in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-18-2009, 07:25 AM
  7. Export as Textfile with VBA
    By moondark in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-14-2005, 09:45 AM

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