Copy multiple sheet to multiple new workbooks without formulas - VBA

pagrav

New Member
Joined
Jul 6, 2022
Messages
4
Office Version
  1. 2019
Platform
  1. Windows
Hi, used the following (see below) vba code to copy multiple sheets from one workbook and create a new workbook per sheet.

This works great for my use.

But, I want the new workbooks to NOT include formulas, only values. I cant figure out how to implement this code into my excisting code.

Anyone see the solution?

VBA Code:
Sub MoveSheets()
 Dim sPath As String, sAddress As String, wsCur As Worksheet
 Dim arrNoMoveSh, mtchSh

 arrNoMoveSh = Split("Kjøretøyinfo,Anleggsregister,Forklaring+Macro", ",")  'This code prevents the macro from making new copies of this sheets

 sPath = ThisWorkbook.Path & Application.PathSeparator


 For Each wsCur In ThisWorkbook.Worksheets
      mtchSh = Application.Match(wsCur.Name, arrNoMoveSh, 0)
      
      
      If IsError(mtchSh) Then 
          wsCur.Copy 
          
        ActiveWorkbook.Close savechanges:=True, Filename:=sPath & wsCur.Name & " - " & Format(Now(), "DDMMYYYY") & ".xlsx"
       
     End If
 Next wsCur
End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Finally my Google searches paid off - added this and the copies are now without formulas

VBA Code:
Sub MoveSheets()
 Dim sPath As String, sAddress As String, wsCur As Worksheet
 Dim arrNoMoveSh, mtchSh

 arrNoMoveSh = Split("Kjøretøyinfo,Anleggsregister,Forklaring+Macro", ",")  'This code prevents the macro from making new copies of this sheets

 sPath = ThisWorkbook.Path & Application.PathSeparator


 For Each wsCur In ThisWorkbook.Worksheets
      mtchSh = Application.Match(wsCur.Name, arrNoMoveSh, 0)
      
      
      If IsError(mtchSh) Then 
          wsCur.Copy 
          
[COLOR=rgb(250, 197, 28)] Cells.Copy
          Range("A1").PasteSpecial Paste:=xlPasteValues
          Application.CutCopyMode = False[/COLOR]
        ActiveWorkbook.Close savechanges:=True, Filename:=sPath & wsCur.Name & " - " & Format(Now(), "DDMMYYYY") & ".xlsx"
       
     End If
 Next wsCur
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,797
Messages
6,121,629
Members
449,041
Latest member
Postman24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top