+ Reply to Thread
Results 1 to 12 of 12

Macros To Save Worksheet as New xlsx file & Save Another Worksheet As A Text File

Hybrid View

  1. #1
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Macros To Save Worksheet as New xlsx file & Save Another Worksheet As A Text File

    Hi

    Code with a few changes

    Sub Steffen()
    
    Open "C:\\Users\Path\" & Sheets(4).Range("C6").Value & ".txt" For Append As #1
        For i = 1 To Sheets(3).UsedRange.Rows.Count
            Print #1, Sheets(3).Cells(i, 1).Value
        Next i
    Close #1
    
    On Error GoTo err
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs "C:\Users\Path\" & Sheets(4).Range("C8").Value & ".xlsx", FileFormat:=51
    err:
    Application.DisplayAlerts = True
    
    End Sub

  2. #2
    Registered User
    Join Date
    11-05-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Macros To Save Worksheet as New xlsx file & Save Another Worksheet As A Text File

    Hi Steffen,

    Having tested and modified your earlier post I was just about to reply to explain the problems that were left. And now I've found that you've already spotted them so that's saved me some writing. Thank you.

    The code works brilliantly except for one thing. When the xlsx file is created I only want the sheet "Data Sheet" to be saved not the whole workbook.

    Regards

    Keith

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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