I'm so close to having this code right but it keeps getting hung up on the SaveAs line. I had it working and then added the EntireColumn.AutoFit section. Though when I remove that section again, it still doesn't work. I must have changed something else but don't remember.... I hope someone else can see what I am not seeing. Including screenshot and text of the code below.
VBA Code:
'Copy Data from ClothingReport tabs,
' paste Values Only in new File called (companyacronym)ClothingReport.xlsx,
' save new file to the \\wtsgoanywhere\iCoStore-CA\Ready to Import\ folder,
' new file name to match tab name with .xlsx extension
' Will save over existing file if one is already saved in that folder
Sub CopyPasteClothingReport_SRG()
Application.DisplayAlerts = False
'Define Ranges for Source and Destination
Dim wbTarget As Workbook 'Target Workbook
Dim rgSource As Range 'Range file and tab names
Dim wk As Workbook
'add new workbook
Workbooks.Add
Set wbTarget = ActiveWorkbook
'Set rgSource = [current workbook].[worksheet(tab name)].[range(start:end)]
Set rgSource = ThisWorkbook.Worksheets("SRGClothingReport").Range("A3:S1003")
'Set rgDestination = [workbook].[worksheet].[range]
Set rgDestination = ActiveWorkbook.Worksheets("Sheet1").Range("A1")
'Copy Data from Source Range to Clipboard, then paste Values and Number Formatting but No Formulas in Destination Range
rgSource.Copy
rgDestination.PasteSpecial xlPasteValuesAndNumberFormats
'Adjust Columns to Auto fit to Contents
Cells.Select
Cells.EntireColumn.AutoFit
'Save New Workbook As Tab Name from Copied Data
ActiveWorkbook.SaveAs filename:=ThisWorkbook.Path & Application.PathSeparator & "Ready to Import" & Application.PathSeparator & "SRGClothingReport.xlsx", FileFormat:=51
'Close active workbook
ActiveWorkbook.Close
'Remove Dancing Ants from copy section
Application.CutCopyMode = False
Application.DisplayAlerts = True
End Sub
Last edited by a moderator: