copy sheet paste values only

rjmdc

Well-known Member
Joined
Apr 29, 2020
Messages
672
Office Version
  1. 365
Platform
  1. Windows
i am doing something wrong
it creates 2 new workbooks not 1, one with the first table and one with the other
then it fails onthe save
dont comment on the call refresh that part works

i want 1 copy of the worksheet and paste and save
Rich (BB code):
Sub ExportFile()
    Dim wb                  As New Workbook
    Dim SaveFolder1         As String:          SaveFolder1 = "M:\my folder\Complete\"
    Dim FileName            As String
    Dim FileDateTime        As String:          FileDateTime = Format(Now, "m-d-yy hh-mm")
    Dim FullFileName        As String
    Dim tbl                 As ListObject

Call RefreshBook
   
        Worksheets("Check").Copy
        FileName = "Check " & Replace(Range("G3"), "/", ".")
        FullFileName = Replace(FileName, ".xlsx", "") ' & " (" & FileDateTime & ")"
    
    Set wb = Workbooks.Add it creates 2 books
    With wb
        .Activate
        .Sheets(1).Range("A1").PasteSpecial Paste:=xlPasteValues it fails here
        .Sheets(1).Name = "Check"
        Selection.Columns.AutoFit
    End With

    'Save and Close New WB
    wb.SaveAs SaveFolder1 & FullFileName & ".xlsx", xlOpenXMLWorkbook
    wb.Close SaveChanges:=False
    DoEvents

    'Back to Main WB
    ThisWorkbook.Activate
    
    MsgBox "Process Complete"

End Sub
 
this was perfect thank you
now next issue with this book
copy specific sheets only not just 1
do i copy paste each one separately or all at once
ex copy sheets check, data, match, fraud
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
thanks i am failing now as i need to copy
sheets2 -7
what do i need to add to the code to make it work
 
Upvote 0
this was perfect thank you
now next issue with this book
copy specific sheets only not just 1
do i copy paste each one separately or all at once
ex copy sheets check, data, match, fraud
They are comments that you must add in your original post.
Now, are you asking me if you want to copy the sheets together or separately?
It is something that you must specify.
You should close this thread and create a new one with the specifications of what you need.
 
Upvote 0

Forum statistics

Threads
1,214,921
Messages
6,122,280
Members
449,075
Latest member
staticfluids

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