Hi Experts In my file "MAINSTORE.xls" I have a worksheet named "Old Items" have to import in the file Backup.xls .With in my limitation I created a macro by recording. The main problem is that it is not importing in a format that I crated in the file MAINSTORE.XLS.Besides that it is looks little bit complicated & big.Pls make the necessary correction in it, if I want to operate this command in the Mainstore.xls ,i.e. for exporting how can I do.
Sub Macro1() Dim name As String Sheets.Add Application.Run "Backup.xls!Macro2" name = Val(Range("a1").Text) ActiveSheet.Select ActiveSheet.name = name End Sub Sub Macro2() With ActiveSheet.QueryTables.Add(Connection:=Array( _ "OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=C:\Documents and Settings\Computer\Desktop\MAINSTORE.xls;" _ , _ "Mode=Share Deny WriteJet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database " _ , _ "Password="""";Jet OLEDB:Engine Type=35;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk" _ , _ " Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet O" _ , _ "LEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False" _ ), Destination:=Range("a1")) .CommandType = xlCmdTable .CommandText = Array("'OLD ITEMS$'") .name = "MAINSTORE" .SaveData = True .SourceDataFile = _ "C:\Documents and Settings\Computer\Desktop\MAINSTORE.xls" .Refresh BackgroundQuery = True End With End Sub Regards Rajesh Kainikkara -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/pages/discussexcelcom/160307843985936?v=wall&ref=ts