+ Reply to Thread
Results 1 to 6 of 6

Copying specific rows from an open workbook into the next row of a closed workbook.

  1. #1
    Registered User
    Join Date
    09-05-2012
    Location
    Philadelphia, USA
    MS-Off Ver
    2010
    Posts
    3

    Copying specific rows from an open workbook into the next row of a closed workbook.

    Hi, I am new to this site and relatively new and self taught with VBA. I have a problem with some code where I am trying to copy certain rows of data (columns A:AG) from an open workbook, sheet name "HRIS FIN Sample File" (which will have daily variable length rows but with column data fixed) where a value in row CH = "Change" and append this to a closed workbook to the next free row of data on worksheet "HRIS Log". The closed file will be added to on a daily basis with all previous data added left intact for comment. I have tried the code below and it opens the specified destination file but it will only copy one line before it stops. I also want to save and close the destination file with the code but haven't got anywhere with this at all yet! Any assistance would be very much appreciated. I got the code online and moved the set DWS line as otherwise for each row, the macro tried to reopen the already open file? Thanks for any help!! Nigel.

    Please Login or Register  to view this content.
    Last edited by arlu1201; 09-05-2012 at 12:01 PM.

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

    Re: Copying specific rows from an open workbook into the next row of a closed workbook.

    Welcome to the forum.

    I have added code tags to your post. As per forum rule 3, you need to use them whenever you put any code in your post. Please add them in future. If you need more information on how to use them, check my signature.
    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]

  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: Copying specific rows from an open workbook into the next row of a closed workbook.

    You need to put the workbook and sheet name before this line
    Please Login or Register  to view this content.
    like maybe
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    09-05-2012
    Location
    Philadelphia, USA
    MS-Off Ver
    2010
    Posts
    3

    Re: Copying specific rows from an open workbook into the next row of a closed workbook.

    Hi Arlette, thanks for getting back so quickly and letting me know about the code tags etc. Hopefully I will learn as I go! I amended the code as below for your suggestion (funnily enough I had already added this!) but the code only copies the first row of data with "Change" in column CH and then stops although there are more lines with "Change" in column CH?? Any ideas why as the code makes sense logically so I'm a bit confused as to what the problem is? Also do you know a way to save and close the destination file "DWS" after running? Thanks again. Nigel

    Please Login or Register  to view this content.

  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: Copying specific rows from an open workbook into the next row of a closed workbook.

    You have marked this solved. Is it?

    If you solve a problem yourself before anyone else has responded, please take a moment to describe your solution, chances are some other member will benefit.

  6. #6
    Registered User
    Join Date
    09-05-2012
    Location
    Philadelphia, USA
    MS-Off Ver
    2010
    Posts
    3

    Re: Copying specific rows from an open workbook into the next row of a closed workbook.

    Hi, yes I solved the issue myself. The code I preiously added had an issue when trying to locate the next row to copy to in the destination WB. My final working code with save and close is as follows:

    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