+ 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,

    Sub Steffen()
    
    Dim newWb As Workbook
    Dim oldWb As Workbook
    
    Set oldWb = ThisWorkbook
    
    Open "C:\Users\Keith\Documents\ATest\" & 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
    
    Sheets(2).Range("A:K").Copy
    Application.DisplayAlerts = False
    Set newWb = Workbooks.Add
        With newWb
            .Sheets(1).Range("A1").PasteSpecial xlPasteAll
            .Sheets(1).UsedRange.RowHeight = 12.75
            With Sheets(1).PageSetup
            .PrintArea = oldWb.Sheets(3).PageSetup.PrintArea
            .Orientation = xlLandscape
            .PrintGridlines = True
            .CenterHeader = oldWb.Sheets(4).Range("C3") & "_" & oldWb.Sheets(4).Range("C4")
            .Zoom = 85
            End With
            .SaveAs "C:\Users\keith\Documents\ATest\" & oldWb.Sheets(4).Range("C8").Value & ".xlsx", FileFormat:=51
            .Close
        End With
    On Error GoTo err
    
    err:
    Application.DisplayAlerts = True
    
    End Sub
    Please take time to read the forum rules

  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

    Steffen,

    That works a treat. Thank you very much for your efforts and for your patience. Really appreciated.

    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