Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,420
    Thanks
    124
    Thanked 5 Times in 5 Posts
    I have a workbook (Br1) that uses a macro to extract the following worksheets "summary", "NV Summary", "UV Summary", "Service", "Parts", "Total NP" and then saves the workbook with an extension.summary i.e Br1.summary

    I need code that will range value all the sheets in the workbook.summary

    Your assistance will be most appreciated

    Sub extract files()
    Dim lCount As Long
    Dim vFilenames As Variant
    Dim sPath As String
    Dim lFilecount As Long
    Dim sFullName As String
    sPath = "c:\Z_accts"
    ChDrive sPath
    ChDir sPath
    vFilenames = Application.GetOpenFilename("Microsoft Excel files (*.xls),*.xls", , "Please select the file(s) to open", , True)
    If TypeName(vFilenames) = "Boolean" Then Exit Sub
    For lCount = LBound(vFilenames) To UBound(vFilenames)
    Workbooks.Open vFilenames(lCount)
    Sheets(Array("summary", "NV Summary", "UV Summary", "Service", "Parts", "Total NP")).Copy
    ActiveWorkbook.SaveAs Replace(vFilenames(lCount), ".xls", "") & ".summary.xls"
    vFilenames(lCount) = ActiveWorkbook.FullName
    With Sheets(Array("summary", "NV Summary", "UV Summary", "Service", "Parts", "Total NP"))
    .UsedRange.Formula = .UsedRange.Value
    End With
    ActiveWorkbook.Close False
    Next
    end sub

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Howard,

    Try this:
    Code:
        With ActiveSheet.UsedRange
            .Copy
            .PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
             :=False, Transpose:=False
             Application.CutCopyMode = False
        End With
    RG
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,420
    Thanks
    124
    Thanked 5 Times in 5 Posts
    Hi RG

    Thanks for the help, much appreciated

    Regards

    Howard
    .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •