Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Reply
 
LinkBack Thread Tools Display Modes
Old 13-05-2011, 06:06 PM   #1 (permalink)
In The Zone
 
arian29's Avatar
 
Join Date: Feb 2008
Location: New Delhi
Posts: 212
Arrow transfering data from file to file using vba


I need to copy a set of data from one excel file to anoter. I am writing the code (vba) in file A and need to copy the data from file B to file A. I wrote the below code, its opening the file B and copying it but is not pasting it in file B which i open already. Need help...

Function transfer()

Dim wbk As Workbook

FirstFile = "D:\P.xls"
FinalFile = "D:\late.xlsm"

Set wbk = Workbooks.Open(FirstFile)
With wbk.Sheets("CIP")

Range("A2:A90").Select
Selection.Copy

End With

Set wbk = Workbooks.Open(FinalFile)
With wbk.Sheets("All data")
Range("A2").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

End With

End Function
__________________
http://www.twitter.com/arian29
ScAn My AvAtAr
arian29 is offline   Reply With Quote
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 13-05-2011, 06:36 PM   #2 (permalink)
Simply a DIGITian
 
krishnandu.sarkar's Avatar
 
Join Date: Nov 2007
Location: Kolkata
Posts: 2,942
Default Re: transfering data from file to file using vba

Well, I'm not 100% sure, but I think open the FinalFile with diff. variable that FirstFile. As far I think coping it doesn't copies to clipboard and then paste from there, as clipboard is a program which is written by OS Manufacturer to make our job easy.

So say for opening FinalFile don't use wbk rather declare another variable, say wbkfinal and use it to open FinalFile workbook.
__________________
  • Read The Forum RULES First.
  • Before PM'ing Or Asking Any Questions To Any Mod Read The FAQ's
  • Before Starting A New Thread Read The STICKY THREADS First
  • Before Participating In Bazaar Section Read The BAZAAR RULES
krishnandu.sarkar is online now   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by Charan
- by Sarath
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 12:28 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2