+ Reply to Thread
Results 1 to 13 of 13

VBA to Export column data from open workbook to next available column of closed workbook?

  1. #1
    Registered User
    Join Date
    05-05-2012
    Location
    New Hampshire
    MS-Off Ver
    Excel 2007
    Posts
    52

    VBA to Export column data from open workbook to next available column of closed workbook?

    Hello again Gurus,

    I am looking for a bit of VBA code to export data with a button trigger only from an open worksheet tab named JOB COSTING of a workbook, column (E13 thru row E2164 only) to the next available column of a closed workbook named INVENTORY.xlsm worksheet tab name CARROLL, starting with column (AA13 thru row AA2164). I am also looking for the code to add a column header of the info in cell D:3 of the active open worksheet tab named JOB COSTING to the closed workbook tab named INVENTORY.xlsm cell AA:12 or what ever the next available column will be.

    I have multiple tabs in the INVENTORY workbook that will add together on the TOTAL INVENTORY worksheet tab, so I will have to tweak the vba code depending on what JOB COST workbook I have open will determine what tab name on the INVENTORY workbook the new columns will add to each time.

    Thanks for any and all suggestions or help in advance.
    Attached Files Attached Files
    Last edited by NicksDad; 05-17-2013 at 02:47 PM. Reason: INCLUDE WOORKBOOKS

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to Export column data from open workbook to next available column of closed workbo

    Do you really mean a closed Workbook or would just not active suffice? To modify a closed Workbook, we'd need to use outdated code. But to modify an open workbook we could use regular contemporary VBA.

    BTW can you post sample workbooks?
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    05-05-2012
    Location
    New Hampshire
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: VBA to Export column data from open workbook to next available column of closed workbo

    xladept,
    The workbook that will be receiving the data will not be open. I guess the vba can open the workbook post data then close the workbook.

    (I uploaded a copy of the JOB COSTING workbook, but the INVENTORY workbook is too large of a file to post, I even stripped out most code and only tried to upload one of the sheets and it was still too large).

    Thanks....

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to Export column data from open workbook to next available column of closed workbo

    Open, Post, Close that's most viable - will we be posting to established records or making new lines??

  5. #5
    Registered User
    Join Date
    05-05-2012
    Location
    New Hampshire
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: VBA to Export column data from open workbook to next available column of closed workbo

    Quote Originally Posted by xladept View Post
    Open, Post, Close that's most viable - will we be posting to established records or making new lines??
    xladept,

    I would like to have the data inserted in the next available new column and line for each.

    example: when button pushed the new data will be inserted in an empty column and lines AA13:AA2164 the next time the button is pushed the data will be entered in the next empty column and lines AB13:AB2164

    Thanks again,
    Jerry.

  6. #6
    Registered User
    Join Date
    05-05-2012
    Location
    New Hampshire
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: VBA to Export column data from open workbook to next available column of closed workbo

    Quote Originally Posted by NicksDad View Post
    xladept,

    I would like to have the data inserted in the next available new column and line for each.

    example: when button pushed the new data will be inserted in an empty column and lines AA13:AA2164 the next time the button is pushed the data will be entered in the next empty column and lines AB13:AB2164

    Thanks again,
    Jerry.
    xladept, no new lines will be added, it will just copy line for line from one workbook to the next, I have more lines for items then will be needed in the near future.

    Thank,
    Jerry.

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to Export column data from open workbook to next available column of closed workbo

    Hi Nick's Dad,

    You'll need to tweak this - the stickiest point is probably the path of the "closed" book.

    Please Login or Register  to view this content.
    Last edited by xladept; 05-17-2013 at 09:42 PM.

  8. #8
    Registered User
    Join Date
    05-05-2012
    Location
    New Hampshire
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: VBA to Export column data from open workbook to next available column of closed workbo

    Quote Originally Posted by xladept View Post
    Hi Nick's Dad,

    You'll need to tweak this - the stickiest point is probably the path of the "closed" book.

    Please Login or Register  to view this content.
    xladept,

    It worked like a charm right from the start. It is just what I was looking for, GREAT JOB and THANKS so much...........

    This is the part I could not get when I tried to do it on my own, I was so stuck.
    Please Login or Register  to view this content.
    Thanks again.
    Jerry

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to Export column data from open workbook to next available column of closed workbo

    You're welcome! Let me know if you ever get stuck again

  10. #10
    Registered User
    Join Date
    05-05-2012
    Location
    New Hampshire
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: VBA to Export column data from open workbook to next available column of closed workbo

    Hi xladept,

    Sorry to bother you and starting this Thread up again, but you did say if i got stuck on this to let you know, well I did get stuck again.
    I tried to make a few changes in the code to match changes I made in the two workbooks.
    the copy works but with a #REF! in the new copied cells and the next time the code is rune it stops with a TYPE MISMATCH error.

    I have spent hours trying to fix what I am sure is a simple fix

    here is the new code.

    Please Login or Register  to view this content.
    I do not know why the code works when I change the to be copied cells to other cells in the workbook, but the cells I want to copy gives #REF!

    Thanks, NicksDad.

    I have attached a copy of the page that sends the code to the INVENTORY workbook, this site would not let me upload a copy of INVENTORY workbooks to large.
    Attached Files Attached Files
    Last edited by NicksDad; 06-30-2013 at 07:17 PM. Reason: wrong workbook, changed to the correct one.

  11. #11
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to Export column data from open workbook to next available column of closed workbo

    I've been looking at your new code and I've been trying it. See if it works (take precautions):

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    05-05-2012
    Location
    New Hampshire
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: VBA to Export column data from open workbook to next available column of closed workbo

    Quote Originally Posted by xladept View Post
    I've been looking at your new code and I've been trying it. See if it works (take precautions):

    Please Login or Register  to view this content.
    when I run the new code you gave me I get a TYPE MISMATCH error.

    I have tried it a few ways and still get #REF! error in the copied cells of the INVENTORY workbook.
    when I use this part of the old code.

    Please Login or Register  to view this content.

    Attached is what the file looks like when done.
    Thanks.
    Attached Files Attached Files
    Last edited by NicksDad; 06-30-2013 at 09:21 PM. Reason: added file

  13. #13
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to Export column data from open workbook to next available column of closed workbo

    Hi NicksDad,

    I'm stuck without that inventory - so, if you will, you can email it to me: [email protected]

+ 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