Hi matthias
Try this basic code example
Sub TestCopy()
If Sheets("Sheet1").Range("A2").Value = Sheets("Sheet2").Range("A2").Value Then
If Sheets("Sheet1").Range("A2").Value = Sheets("Sheet3").Range("A2").Value Then
Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Copy
Else
Sheets(Array("Sheet1", "Sheet2")).Copy
End If
Else
If Sheets("Sheet1").Range("A2").Value = Sheets("Sheet3").Range("A2").Value Then
Sheets(Array("Sheet1", "Sheet3")).Copy
Else
Sheets("Sheet1").Copy
End If
End If
Worksheets.Select
Cells.Copy
Cells.PasteSpecial xlPasteValues
Cells(1).Select
Worksheets(1).Select
Application.CutCopyMode = False
End Sub
--
Regards Ron de Bruin
http://www.rondebruin.nl
"matthias" wrote in message oups.com...
Hi guys,
i want a macro to do the following:
I have a masterfile with several sheets. If I run the macro i want it
to copy sheet1 and/orsheet2 and /or sheet 3 to a new workbook
depending on a condition.
Sheet 1 has to be copied always
Sheet 2 has to be copied only if the cell A2 from sheet 1 is the same
as the cell A2 from sheet 2
Sheet 3 has to be copied only if the cell A2 from sheet 1 is the same
as the cell A2 from sheet3
the sheets have to be copied as values and with the format off the
sheets from the masterfile.
Thanks guys
mat