Hello
I want to save the active workbook with all its tabs on a new workbook only as values -all the tabs still individually at the new work book- StephenCrump helped me with the following code but it saves all the active workbook's tabs at just one tab on the new work book I want them to be just as they were on the old one but as values only
Thanks
VBA Code:
Sub SaveValues()
Dim SourceBook As Workbook, DestBook As Workbook, SourceSheet As Worksheet, DestSheet As Worksheet
Dim SavePath As String
Dim LastRow As Long, i As Long, count As Long
Application.ScreenUpdating = False
Set SourceBook = ThisWorkbook
'*********************************************
'Edit next two lines as necessary
SavePath = Sheets("Sheet1").Range("F7").Text
'*********************************************
Application.DefaultSheetDirection = xlRTL 'if necessary
Set DestBook = Workbooks.Add
Application.DisplayAlerts = False
For i = DestBook.Worksheets.count To 2 Step -1
DestBook.Worksheets(i).Delete
Next i
Set DestSheet = DestBook.Worksheets(1)
Application.DisplayAlerts = True
count = 1
For Each SourceSheet In SourceBook.Worksheets
With SourceSheet
LastRow = .Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlFormulas).Row
.Range("1:" & LastRow).Copy
With DestSheet.Range("A" & count)
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteFormats
End With
count = count + LastRow
End With
Next SourceSheet
DestSheet.Name = "Some name"
DestBook.Activate
With ActiveWindow
.DisplayGridlines = False
.DisplayWorkbookTabs = False
End With
SourceBook.Activate
Application.DisplayAlerts = False 'Delete if you want overwrite warning
DestBook.SaveAs Filename:=SavePath
Application.DisplayAlerts = True 'Delete if you delete other line
SavePath = DestBook.FullName
DestBook.Close 'Delete if you want to leave copy open
MsgBox ("A copy has been saved to " & SavePath)
Application.DefaultSheetDirection = xlLTR 'if necessary
End Sub
[/CODE]
I want to save the active workbook with all its tabs on a new workbook only as values -all the tabs still individually at the new work book- StephenCrump helped me with the following code but it saves all the active workbook's tabs at just one tab on the new work book I want them to be just as they were on the old one but as values only
Thanks
VBA Code:
Sub SaveValues()
Dim SourceBook As Workbook, DestBook As Workbook, SourceSheet As Worksheet, DestSheet As Worksheet
Dim SavePath As String
Dim LastRow As Long, i As Long, count As Long
Application.ScreenUpdating = False
Set SourceBook = ThisWorkbook
'*********************************************
'Edit next two lines as necessary
SavePath = Sheets("Sheet1").Range("F7").Text
'*********************************************
Application.DefaultSheetDirection = xlRTL 'if necessary
Set DestBook = Workbooks.Add
Application.DisplayAlerts = False
For i = DestBook.Worksheets.count To 2 Step -1
DestBook.Worksheets(i).Delete
Next i
Set DestSheet = DestBook.Worksheets(1)
Application.DisplayAlerts = True
count = 1
For Each SourceSheet In SourceBook.Worksheets
With SourceSheet
LastRow = .Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlFormulas).Row
.Range("1:" & LastRow).Copy
With DestSheet.Range("A" & count)
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteFormats
End With
count = count + LastRow
End With
Next SourceSheet
DestSheet.Name = "Some name"
DestBook.Activate
With ActiveWindow
.DisplayGridlines = False
.DisplayWorkbookTabs = False
End With
SourceBook.Activate
Application.DisplayAlerts = False 'Delete if you want overwrite warning
DestBook.SaveAs Filename:=SavePath
Application.DisplayAlerts = True 'Delete if you delete other line
SavePath = DestBook.FullName
DestBook.Close 'Delete if you want to leave copy open
MsgBox ("A copy has been saved to " & SavePath)
Application.DefaultSheetDirection = xlLTR 'if necessary
End Sub
[/CODE]
Last edited: