Question : Can I copy data from one excel workbook into another without the second workbook visably opening?

Hi all,
I need a macro that will copy all the data from the current sheet of an open excel work book, and then create a new sheet in a closed workbook to paste the data onto.  The new sheet ideally needs to be renamed with "todays" date and the paste need to be a paste special, values then formats.  

From browsing the web I realise that the closed workbook will be open but running behind the scenes which is fine.  

I am pretty new to VBA and have tried to adapt the code for pasting into an open workbook and also adapting other peoples codes but I feel that I am in over my head.

Your help and patience will be greatly appreciated,

Ben

Answer : Can I copy data from one excel workbook into another without the second workbook visably opening?

Hi Ben,

Ahammar's code will copy the contents of a range to the active sheet in another workbook very quickly and accurately without the user seeing the copy paste but, it does not grab the entire sheet nor does it add a new worksheet to the saved workbook and name it with the current date.  

Here's some code that will paste the contents of the active worksheet into another workbook on a tab with the current date  without the user seeing the copy paste special format and values.  Ahammer's code is more expertly written than mine so you might want to re-write mine using his style.  Hope it helps.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
Sub CopyPasteIntoOtherWB()
 
    Application.ScreenUpdating = False
    Workbooks.Open Filename:="C:\File2.xls" 'Path to workbook to open and paste into
    Sheets.Add.Name = "MyNewWorksheet" 'Temporary new worksheet name
    ActiveCell.FormulaR1C1 = "=CONCATENATE(TEXT(NOW(),""[$-409]d-mmm-yy;@""))" 'Current Date
    Selection.Copy
    Selection.PasteSpecial (xlPasteValues)
    Sheets("MyNewWorksheet").Name = Range("A1").Value 'Renaming new worksheet to current date
    ActiveWorkbook.Save
    ActiveWindow.Close
    Selection.SpecialCells(xlCellTypeLastCell).Select  'Selecting everything on active worksheet
    Range(Selection, Cells(1)).Select
    Selection.Copy
    Workbooks.Open Filename:="C:\File2.xls"
    Selection.PasteSpecial (xlPasteFormats) 'Pasting Formats
    Selection.PasteSpecial (xlPasteValues)  'Pasting Values
    ActiveCell.Select
    Application.CutCopyMode = False
    ActiveWorkbook.Save
    ActiveWindow.Close
    Range("A1").Select
 
End Sub
Random Solutions  
 
programming4us programming4us