Hello,
I've found similar posts on here similar to my issue, but I've been unable to get any of the proposed solutions to work. I have a workbook that I filter and then copy to a brand new workbook. I'm trying to save it to a location on One Drive. It's strange because most of the time it fails, but every once in a while (5% of the time) without changing anything, it completes successfully. It stops at the "ActiveWorkbook.SaveAs Path & FileName, xlOpenXMLWorkbook" line in the code. What am I doing wrong?
I've found similar posts on here similar to my issue, but I've been unable to get any of the proposed solutions to work. I have a workbook that I filter and then copy to a brand new workbook. I'm trying to save it to a location on One Drive. It's strange because most of the time it fails, but every once in a while (5% of the time) without changing anything, it completes successfully. It stops at the "ActiveWorkbook.SaveAs Path & FileName, xlOpenXMLWorkbook" line in the code. What am I doing wrong?
VBA Code:
Sub Create()
'
' Create Macro
'
'
Dim Path As String
Dim FileName As String
Range("E3").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("NonSpon").Select
ActiveSheet.Range("$A:$H").AutoFilter Field:=3, Criteria1:=Worksheets("Macro").Range("E3").Value
Range("A1:J1").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Columns("A:H").Select
Columns("A:H").EntireColumn.AutoFit
Range("A1").Select
Application.CutCopyMode = False
FileName = Range("J1").Value & ".xlsx"
Path = "https://testfwt.sharepoint.com/sites/testFinance/Shared%20Documents/DNU-Invoice%20Support/Support%20Files/"
ActiveWorkbook.SaveAs Path & FileName, xlOpenXMLWorkbook
ActiveWindow.Close
Range("A1").Select
ActiveSheet.ShowAllData
Sheets("Macro").Select
Range("E4").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Cut
Range("E3").Select
ActiveSheet.Paste
Range("E3").Select
If ActiveSheet.Range("E3").Value = "" Then Exit Sub
Call Create
End Sub