I have a workbook with many worksheets. I am attempting to use the below macro to cycle the worksheets, copy and paste value, then save off individually in a location.
I feel like I'm glossing over something very small and beginning to go bonkers. Currently this code copies and pastes value the first worksheet, and then saves the rest off without the copy/paste. So everything is working as desired with the exception of the copy/paste value not occurring with each worksheet.
Sub SaveFilesInFolder()
'
'This is for saving each worksheet as a workbook in a destination folder as an excel file
'
'
Dim sh As Worksheet
Dim wb As Workbook
For Each sh In Worksheets
With ActiveWorkbook
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
SheetName = sh.Name
sh.Copy
.SaveAs Filename:="C:\Location\" & SheetName
.Close SaveChanges:=True
End With
Next sh
End Sub
Any and all assistance is greatly appreciated.
Edit:
Below is the updated code from comments. Unfortunately, the sheet is still copying/pasting for the first worksheet and not the rest. Everything is saving in the specified location as intended.
Sub SaveFilesInFolder()
'
'This is for saving each worksheet as a workbook in a destination folder as an excel file
'
'
Dim sh As Worksheet
Dim wb As Workbook
Dim rng As Range
For Each sh In ThisWorkbook.Worksheets
Set rng = Cells
rng.Copy
rng.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
sh.Copy
ActiveWorkbook.SaveAs ("C:\Location\" & sh.Name)
ActiveWorkbook.Close
Next sh
End Sub