+ Reply to Thread
Results 1 to 11 of 11

Move ranges from workbook to workbook based on cell value

  1. #1
    Registered User
    Join Date
    09-25-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    62

    Move ranges from workbook to workbook based on cell value

    New user trying again but simplifying my query.
    I need to move 2 ranges (Datarange and Spreadsheetrange) in one workbook into two different workbooks.
    Which workbook receives which range is based on user input (Sheet M16, cells A1 and A11).
    I think searching destination workbook file to match user input and then adding range to end of data is logic needed.
    I don't know VBA well enough to accomplish this unfortunately.

    Attached is workbook with both ranges on sheet M16.

    Any and all help is appreciated!
    Last edited by SLIDE1; 10-03-2012 at 01:20 AM.

  2. #2
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: Move ranges from workbook to workbook based on cell value

    no workbook attached?

  3. #3
    Registered User
    Join Date
    09-25-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    62

    Re: Move ranges from workbook to workbook based on cell value

    Sorry about that..I was trying to upload the latest re. of the workbook.
    didn't have much luck.

  4. #4
    Registered User
    Join Date
    09-25-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    62

    Re: Move ranges from workbook to workbook based on cell value

    ATTACHMENT NOW CORRECT..

  5. #5
    Registered User
    Join Date
    09-25-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    62

    Re: Move ranges from workbook to workbook based on cell value

    Wondering now if this is even possible. I will give it one more day then mark it solved.

  6. #6
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: Move ranges from workbook to workbook based on cell value

    im sure its possible, but this may be a bit beyond me, but ill try my best and im sure the information I ask will help others to help you. You want to split data from sheet M16 and move it to a workbook depending on whats in A1, and A11 (so there would be 3 total workbooks for this file, the first you started, a kq034 workbook, and a kq034-a workbook. Now im assuming that the next time, you might change A1, and A11, say A1 becomes KQ091, you would want a corresponding workbook to be created or data entered into it, is that correct? Also, would this data replace whats in the workbook or just build up on each next row? And where are you getting the data to be entered from? Can you give me sample user data that they would enter as well?

    Do you just intend to copy A3:C8, after the macro finishes collecting user data, and In the order that its presented on M16?
    Last edited by jayinthe813; 10-03-2012 at 09:29 PM.

  7. #7
    Registered User
    Join Date
    09-25-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    62

    Re: Move ranges from workbook to workbook based on cell value

    jayinthe813,

    First of all thanks for taking a look at this for me.
    You are correct about how the code should work.
    There are 3 workbooks. The 1st workbook has the data is entered into via the user form. The 2 other workbooks that should receive the data already exist in a folder named job#.
    The next user will enter different data so yes that will change cell A1 on the 2nd sheet. All data in 1st workbook should be replaced every time.
    I have 2 workbooks with data in them waiting for more data.
    Here is the sequence that i am trying to achieve to input that additional data.

    1. User opens form and enters data
    2. User selects 'Add to Report" command button
    3. Data populates 2nd sheet of workbook where it is configuered as it needs to be inserted and grouped into 2 ranges.
    4. The correct data range is copied to 2nd and 3rd workbooks at the end of last row. Which workbook is defined by a variable (cells A10 and A20).
    5.All data is cleared from 1st workbook 2nd sheet row 3.

    I am attaching the latest revision of my workbook (Manualinputexample.xlsm).
    The userform is functional and can be used to insert new data as needed to 2nd sheet.
    I am also attaching an example of the 2nd (KP588) and 3rd (KP588-A) workbooks with data inserted.
    If anything else is needed please let me know.

    Once again thanks for taking a look!
    SLIDE1

  8. #8
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: Move ranges from workbook to workbook based on cell value

    how are the job numbers figured? Are they set or are they generated on the fly as you are going

    Also, each time you run the form, are we copying A12:E17 only, as in, thats the only range that will ever occur to export, and then paste into a workbook named after A10?
    Last edited by jayinthe813; 10-03-2012 at 10:48 PM.

  9. #9
    Registered User
    Join Date
    09-25-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    62

    Re: Move ranges from workbook to workbook based on cell value

    yes your example is correct.
    Job# as entered on user form is unique and will not repeat and it is generated by the job that is being measured.

  10. #10
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: Move ranges from workbook to workbook based on cell value

    This is a quick example. You can test this out if you would like. Run this from that main workbook you just uploaded. Create a blank workbook and save it as the job name. I set the below to your network drive but you could create a local folder on your desktop with this workbook and the one you intend to split to and test it that way. Just change the line with the drive to match your setup correctly. Make sure that your file format below is set correctly (xls or xlsx)! This however, will not create a new workbook, yet, so if you want to test it, make a blank workbook. You can step through it to see what it does by using "F8" in the vba editor

    Please Login or Register  to view this content.
    Things to do yet:

    - Check if workbook exists, if not, then create workbook in the network drive directory, and paste the data
    - apply the code to cell A20 to do the same thing as above
    - Clear out your data

    I think you would run this macro after running your user form, and you can chain them together. Once you change the status of the opened excel to invisible, it should appear to seamlessly insert your data into a new file. I will work on the rest of this tomorrow for you, assuming someone else doesn't beat me to it
    Last edited by jayinthe813; 10-03-2012 at 11:18 PM.

  11. #11
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: Move ranges from workbook to workbook based on cell value

    Ok sorry for late reply. I am newer to VBA so forgive me, the code is a bit repetitive (couldve subbed out the jobid with destsheet variables), but with screenupdating off it shouldn't matter. Run this in the sheet, or check out the sub ExportUserForm in the attached sheet.

    Please Login or Register  to view this content.
    Run this a few times with different names in A10/A20 and then run it some more and test it out. It is set to create .xlsx files, assuming you support that, if not you will need to change the file extensions to .xls. Im pretty sure I matched all your drives up. Be Aware, that if you have illegal characters in A10/A20(characters you normally can't save with), the file will not save, and it will bug out. If you hit debug on this, give me the lines and the reason, this macro is dependent upon your network drive being "Ready", keep that in mind

    Manualinput.xlsm
    Last edited by jayinthe813; 10-05-2012 at 10:48 PM.

+ 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