Hi Guys,
Currently, i've got this macro:
Sub CPF()
Dim DestWorkbook As String
Dim strNameWorksheet As String
strNameWorksheet = "CPF"
DestWorkbook = ActiveWorkbook.Name
NewFN = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls; *.xlsx), *.xls; *.xlsx", Title:="Please select a file")
ActiveWorkbook.Save
Dim wb As Workbook
On Error Resume Next
Set wb = Workbooks(DestWorkbook)
On Error GoTo 0
If NewFN = False Then
' They pressed Cancel
MsgBox "Geen bestand geselecteerd"
Exit Sub
Else
End If
If wb Is Nothing Then
Set wb = Workbooks.Open(Filename:=NewFN)
Else
wb.Activate
End If
Sheets(2).Select
ActiveSheet.Name = strNameWorksheet
ActiveSheet.Copy After:=Workbooks(DestWorkbook).Sheets(1)
End Sub
This code copies a sheet from one file to another. But, i don't want to copy the sheet, but only the content and place this content in another (already existing) sheet.
I Tried this code
Sheets(2).Select
Selection.Copy
wb.Activate
Sheets(strNameWorksheet).Select
Selection.Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End Sub
But it doesn't seem to work. What do i do wrong?
Bookmarks