Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88854

Copy Worksheet not functioning

$
0
0

My attached code is causing an error when trying to copy over the worksheet into the new workbook, can anyone advise what might be driving this problem?

Sub Excel1()

   Dim rngLoopRange As Range
   Dim wsSummary As Worksheet
   Dim rngDealers As Worksheet

   Set wsSummary = Sheets("PL")

   For Each rngLoopRange In Worksheets("AUX").Range("A1:A38")
      wsSummary.Range("C12").Value = rngLoopRange.Value

    Application.Run "TM1REFRESH"

    Dim wb As Workbook
    Set wb = Workbooks.Add
    ActiveWorkbook.SaveAs filename:=ThisWorkbook.Path & "\"& wsSummary.Range("C12").Value
    ws.Copy before:=wb.Worksheets(1)
    wb.Close savechanges:=True


Next rngLoopRange

Set wsSummary = Nothing

    MsgBox "Complete!", vbInformation

End Sub

Viewing all articles
Browse latest Browse all 88854

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>