Hello, I am trying to copy a sheet from one workbook to the end of another closed workbook. However, the sheet that is being copied contains formulas and I only want the values to be pasted in the closed workbook and I am not too sure how to accomplish this. Also, I am trying to rename the sheet in the closed workbook based on a cell value. My code is below:
VBA Code:
Sub CopySheetToMaster()
Dim closedBook As Workbook
Dim currentSheet As Worksheet
Application.ScreenUpdating = False
Set currentSheet = Application.ActiveSheet
'select location of Master Database Workbook
Set closedBook = Workbooks.Open("C:\Users\filepath\Master Database.xlsm")
currentSheet.Copy After:=closedBook.Sheets(closedBook.Worksheets.Count) 'copy Database sheet from fieldsheet to end of sheets in Master Database Workbook
'renames the new sheet in Master Database as the name in B1
If currentSheet.Range("B1").Value <> "" Then
On Error Resume Next
ActiveSheet.Name = currentSheet.Range("B1").Value
End If
closedBook.Close SaveChanges:=True 'saves the Master Database and closes it
Application.ScreenUpdating = True
End Sub