Dear All,
Below mentioned is the code which I have writen to select, copy and paste the data in new file, but my code is not working. First let me explain what I am looking for.
1) I have Workbook with salary sheet for one company, which I want to break into location.
2) In the workbook, I have two sheet one is Salary and Second is branches.
3) I want to fillter the salary sheet and as per the branches detail mentined in the second sheet.
4) I want to save the filltered data in new worksheet, which is already saved in Demo follder.
Now, my all things are working, but when the macro reached at the level to paste the fillered data on new workbook book it ask to "Select destination and press ENTER or choose paste".
Request you to kindly advice.
Thanks & Regards![]()
Sub Macro2() ' ' Macro2 Macro ' Macro recorded 2/7/2013 by Kumar Gourav ' ' Keyboard Shortcut: Ctrl+Shift+Z ' Windows("salary register demo.xls").Activate Sheets("Branches").Select For i = 1 To 10 Sheet2row = Range("a" & i).Value Fname = "D:\Kumar Gourav\Demo\" & Sheet2row Sheets("Salary").Activate Range("L1").Activate Selection.AutoFilter Range("L1").Select Selection.AutoFilter Field:=12, Criteria1:=Sheet2row Range("a1", "iv3000").Cells.Activate Range(Selection, Selection.End(xlDown)).Select Selection.Copy Workbooks.Open Fname Range("A1", "a1").Activate Selection.Paste ActiveWorkbook.Close savechanges:=True Workbooks("Salary register Demo").Activate Next i End Sub
Kumar Gourav
Bookmarks