Results 1 to 4 of 4

VBA code to export data to txt file

Threaded View

  1. #1
    Registered User
    Join Date
    01-22-2014
    Location
    Norge
    MS-Off Ver
    Office 365
    Posts
    55

    VBA code to export data to txt file

    Hi,

    I have the following code that gives me an error when I try to run it:

    Sub MECToTXT()
        Dim Data As Variant
        Dim Filespec As String
        Dim Rng As Range
        
            Filespec = "C:\Users\B31090\Desktop\Logistikkhuset MEC.txt"
            
            Set Rng = Range("H1:K1")
            Set Rng = Range(Rng, Cells(Rows.Count, Rng.Column).End(xlUp))
            
            Open Filespec For Output As #1
                For Each Row In Rng.Rows
                    Data = Row.Value
                    Data = Application.Transpose(Data)
                    Data = Application.Transpose(Data)
                    Data = Application.Transpose(Data)
                  Print #1, """" & Data(1) & """ """ & Data(2) & """ """ & Data(3) & """ """ & Data(4) & """ """ & """"
                Next Row
            Close #1
    Anyone here who can help me to write this code so that it will work properly? I have data in columns H1:K1 and downwards that I would like to have stored as a txt file as you probably see from the code.
    Last edited by Absalon; 11-21-2014 at 07:55 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Issue with X axis values NOT graphing on Scatter graph and issue with Labels
    By lmausolf in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-17-2012, 07:20 AM
  2. [SOLVED] Issue - Attachment issue - by Simon Lloyd
    By Vaibhav in forum Suggestions for Improvement
    Replies: 16
    Last Post: 03-16-2012, 06:56 PM
  3. Issue with programming.
    By alejojauregui in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-04-2008, 01:23 AM
  4. Format/programming issue
    By thetallguy0 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-26-2008, 09:02 AM
  5. Replies: 3
    Last Post: 07-20-2007, 01:09 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