I created successfully a new file using the code below. But when I try to replace the file with new data, it ask me to debug.
Sub CreateFAIDMaster()
Dim dirPath, fName As String, newWb As Workbook, thisWb As Workbook
Set thisWb = ThisWorkbook
dirPath = thisWb.Path
fName = ActiveSheet.Range("m1").Value
Application.ScreenUpdating = False
Set newWb = Workbooks.Add
thisWb.Sheets("FAIDMaster").Range("A1:C50").Copy newWb.Sheets("Sheet1").Range("A1")
newWb.SaveAs Filename:=dirPath & "\" & fName
newWb.Close
Application.ScreenUpdating = True
MsgBox "Workbook created at:" & vbCrLf & vbCrLf & dirPath & "\" & fName
End Sub
Please change the code to replace the existing file with new data.
Sub CreateFAIDMaster()
Dim dirPath, fName As String, newWb As Workbook, thisWb As Workbook
Set thisWb = ThisWorkbook
dirPath = thisWb.Path
fName = ActiveSheet.Range("m1").Value
Application.ScreenUpdating = False
Set newWb = Workbooks.Add
thisWb.Sheets("FAIDMaster").Range("A1:C50").Copy newWb.Sheets("Sheet1").Range("A1")
newWb.SaveAs Filename:=dirPath & "\" & fName
newWb.Close
Application.ScreenUpdating = True
MsgBox "Workbook created at:" & vbCrLf & vbCrLf & dirPath & "\" & fName
End Sub
Please change the code to replace the existing file with new data.