+ Reply to Thread
Results 1 to 4 of 4

Importing from one sheet to another

  1. #1
    Registered User
    Join Date
    10-08-2009
    Location
    Delaware
    MS-Off Ver
    Excel 2007
    Posts
    2

    Importing from one sheet to another

    Hi all, new to the forums with a bit of a problem.

    I have created a script to generate a .xls file each day. I then have another file in excel that houses all data (rows are inserted one after the other) to generate a report.

    My problem is thus far this has been done manually. I would like to do so with a macro or a script.

    Ultimately, I just want to take rows 3 through (bottom row) in my daily report, and insert them into my "final" report starting at final bottom row + 1.

    Kinda new to VB, but have experience with several other languages. Just kinda need a good place to start.

    Thanks in advance

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Importing from one sheet to another

    1) What's the working path to where your master file is stored?
    2) What's the sheet name in the master file where the data needs to be added?
    3) Does the macro need to open the master file, or will you always do that?
    4) Should the macro close the master file when done adding, or should it remain open for your convenience.
    5) Is there an empty cell in your daily sheets that can be used to enter a "Transferred" so this macro doesn't accidentally get run twice on the same sheet?
    6) What's the column range to be included?
    7) Anything else?
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    10-08-2009
    Location
    Delaware
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Importing from one sheet to another

    lets say we have-
    C:\folder1\dataxxxx
    C:\folder2\final_data

    the xxxx in data is an appended date in the script I have when its generated.

    So... in final_data i have the macro. The goal is for it to go into dataxxxx, grab from sheet dataxxxx the rows A5-Q(bottom), and stick em' into final_data.dump in location B(bottom + 1)

    My VB experience is limited, but what I am working on atm is
    ' location of final row and thus +1 the row I want to paste into
    Dim final_data As Long
    final_data = WorkBooks("C:\folder\final_data").Sheets("dump").Range("A999999").End(xlUp).Row

    'location of final row and in this case, the amount I need copied
    Dim data_bottom As Long
    data_bottom = Workbooks("C:\folder1\data" & Year(Date) & Month(Date) & Day(Date) & ".xls").Sheets("data" & Year(Date) & Month(Date) & Day(Date)).Range("A999999").End(xlUp).Row

    I am getting a "subscript out of range" error on this, but it works when I leave out the full path (have to have it open which i want to be optional), and I don't have all the appends.

    Once I can get these to return the values of the final rows, I don't think copying the data over will be an issue.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Importing from one sheet to another

    SLM09, be sure to read through the Forum Rules so you can use and follow them effectively. For instance, you'll need to edit that post above and put code tags around that code you used. (Like I did below...)

    Please Login or Register  to view this content.
    If you will replace your xxxx in dataxxxx.xls with examples of your ACTUAL filenames so we can see the full construct, perhaps we can offer a simple fix to your code.

+ 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