Copy Worksheets to another workbook

I need to create vba code that will copy two specific worksheets from my active workbook to another open workbook. But I need it to paste values and not copy the formulas & links. Can anyone help?
Lawrence SalvucciInformation Technology ManagerAsked:
Who is Participating?
byundtConnect With a Mentor Commented:
I've modifed Jorgen's code so it copies the worksheets and replaces formulas with the values from the original workbook. I also got rid of the need to instantiate a new instance of Excel and to hardcode the names of source and target workbooks.

As revised, the macro assumes that the source workbook is active and that the target workbook is the only other workbook that is open.
Sub CopySheetValues()
Dim wb As Workbook, wbTarg As Workbook
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each wb In Application.Workbooks
    If wb.Name <> ActiveWorkbook.Name Then
        Set wbTarg = wb
        Exit For
    End If
For Each ws In ActiveWorkbook.Sheets(Array("Sheet1", "Sheet2"))
    ws.Copy After:=wbTarg.Sheets(wbTarg.Sheets.Count)
    ActiveSheet.UsedRange.Value = ws.UsedRange.Value
End Sub

Open in new window

JorgenConnect With a Mentor Commented:
Hi isalvucci

If you tried searching for "copy Worksheets to another workbook, you can find more than 5.000 related questions and save yourself some time. I selected no 4 as a solution that was nice VBA code thanks to matthewspatrick.
When you have copied your sheet, create a macro and mark everything in the sheet and copy followed by paste as value.

You can do this nicer, but if you need help on a saturday evening, that will have to be a quick and dirty solution working for you.

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
Set objWorkbook1= objExcel.Workbooks.Open("SourceFile.xlsx")
Set objWorkbook2= objExcel.Workbooks.Open("TargetFile.xlsx")
objWorkbook1.Sheets(Array("Sheet1","Sheet2","Sheet3")).Copy _
set objExcel=nothing
All Courses

From novice to tech pro — start learning today.