+ Reply to Thread
Results 1 to 7 of 7

VBA help - opening files and copying data into an activeworkbook then closing them ag

  1. #1
    Registered User
    Join Date
    02-08-2012
    Location
    redditch
    MS-Off Ver
    Excel 2003
    Posts
    12

    VBA help - opening files and copying data into an activeworkbook then closing them ag

    Hi

    I have report where I have to export data into it from a few different excel / csv files. In my report I want to be able to run a macro that will open up file 1 witha specified filename and path, copy in the data I need from a specified data range into a specified workbook and data range and then do the same again with another file,

    Can anyone help

    Thanks
    Kerrold

  2. #2
    Registered User
    Join Date
    01-24-2012
    Location
    Swindon, England
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: VBA help - opening files and copying data into an activeworkbook then closing the

    What is the problem with recording what you want to do?

  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA help - opening files and copying data into an activeworkbook then closing the

    Sure. This can be done. Do you have a sample file that you can upload?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  4. #4
    Registered User
    Join Date
    02-08-2012
    Location
    redditch
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: VBA help - opening files and copying data into an activeworkbook then closing the

    Hi

    Thank you for your replies so far... I have now recorded this and have got part of it to work.

    How do i specify in the VBA that I want it to copy from cell A2 to the end of the data?

    When I record this part it specifies a data range so when i run the macro again the data range changes and if there is more data than before it doesn't pick it all up?

    Thanks
    Kerry

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA help - opening files and copying data into an activeworkbook then closing the

    Identify the lastrow using this -
    Please Login or Register  to view this content.
    How are you managing with copying from several files? Are you using / running the same code over and over again till your files are done?

  6. #6
    Registered User
    Join Date
    02-08-2012
    Location
    redditch
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: VBA help - opening files and copying data into an activeworkbook then closing the

    Thankyou, will give that a try.

    Yes I have 3 different exports so have duplicated the code amending the file paths and the data ranges accordingly for each one.

    Many thanks
    Kerry

  7. #7
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA help - opening files and copying data into an activeworkbook then closing the

    You can change this code to suit your needs. This code checks a folder for xls files and opens each one and copies the data over. Then closes the file -
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1