+ Reply to Thread
Results 1 to 26 of 26

transfer data from open workbook to closed workbook

  1. #1
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690

    transfer data from open workbook to closed workbook

    hi guys
    im looking for some code to transfer cells a3,d6,f9,i6,k10 and i18 from open workbook named "hello"

    to

    closed workbook named "goodbye" and input to next available row
    a3 to a1
    d6 to a2
    f9 to a3
    i6 to a4
    k10 to a5
    i18 to a6

    thanks in advance
    Last edited by stevesunfold; 12-16-2008 at 03:44 PM.

  2. #2
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    tried recording a macro across the two workbooks to no avail
    all help gratefully received

  3. #3
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    I think the easiest way will be to open the second workbook. This can be done unobtrusively.

  4. #4
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    hi stephen
    i was hoping this would possible without as other users will be using
    maybe the macro could code to open the workbook automatically and then shut and save at same time?

  5. #5
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    Yes, that's what I had in mind. If you turn off ScreenUpdating it won't show on screen.

    EDIT: here's an example. You've got more than 500 posts - see if you can adapt to your needs!

    Please Login or Register  to view this content.
    Last edited by StephenR; 12-16-2008 at 05:11 PM.

  6. #6
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    hi stephen as im not very au fait with code
    i dont really know where to start

  7. #7
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    I find that hard to believe Steve, some of the stuff here must have rubbed off! In effect, instead of
    Please Login or Register  to view this content.
    you need
    Please Login or Register  to view this content.
    Does that make sense?

  8. #8
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    thanks stephen
    will take a look when i get home
    just hope i can work it out
    thanks

  9. #9
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    hi stephen
    i have this code
    Please Login or Register  to view this content.
    and i get an error when i run this

    microsoft visual basic
    400

    any ideas?

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello stevesunfold,

    On which line does the error occur? You will get an faster answer if you include where the error occurs.

    Sincerely,
    Leith Ross

  11. #11
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    doesnt actually highlight a line leith
    thanks for the reply

  12. #12
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello stevesunfold,

    Are you using a Mac?

    Sincerely,
    Leith Ross

  13. #13
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    no leith
    windows xp
    office 2007

  14. #14
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello stevesunfold,

    Ah, I don't have Excel 2007. Seems odd that would have changed VBA to not highlight the line where the error occurred, but stranger things have happened.

    Sincerely,
    Leith Ross

  15. #15
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    just did a quick record macro version and it came up with this
    Please Login or Register  to view this content.
    as you can see its very tatty but it works up to the point of closing the workbook goodbye where it says it already exists do you want to save

    i want this to be yes

    as you can see i only did the first 3 cell transfer instead of 6 to see what the code would be like

    im happy for it to open as long as it closes itself

  16. #16
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    sorry guys bumping again because i think someone out there knows and is kind enough to help

  17. #17
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    I don't see how this would explain your error message, but I made a couple of basic errors in my previous code - the copying was the wrong way round. See if this makes any difference:
    Please Login or Register  to view this content.

  18. #18
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    hi stephen
    many thanks for your response

    getting a message box coming up with
    microsoft visual basic
    400

  19. #19
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    Do you know how to step through the code by going into the editor and pressing F8 to go through each line? Then we may be able to work out what is causing the error because that code works for me. Or perhaps you submit a small example workbook? Otherwise we go round in circles.

    EDIT: error 400 may relate to userforms - could that apply here? Or do you have any protected cells?
    Last edited by StephenR; 12-20-2008 at 01:08 PM.

  20. #20
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    hi stephen and thanks for your help
    here is the file called hello
    there is nothing on the workbook called goodbye at all
    i actually thought i had worked out what was wrong as it is actually an xlsx file but that didnt change anything
    i have also just noticed that when i click the button for the macro to work whatever i have entered into cell a3 disappears
    why is this?
    Attached Files Attached Files
    Last edited by stevesunfold; 12-21-2008 at 11:24 AM.

  21. #21
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    I'm losing my marbles - the code was originally OK and my last correction was wrong as I got confused about where you were copying to/from. The code below works for me - adds the data in goodbye and leaves it intact in hello. I'm using xl2003 but have the file conversion thing, I don't know whether that makes a difference. Try the code below in a standard module in hello.
    Please Login or Register  to view this content.

  22. #22
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    Stephen
    that is absolutely superb and works the only thing i did was tell you the destinations cells were wrong.
    it should have been a1,b1,c1,d1,e1,f1 but i worked that out
    thanks very very much
    how is the code adapted so that the next time i run it it will go to the next available row?
    ie the next time i click it will go to a2,b2,c2,d2,e2,f2

    many thanks

  23. #23
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    Steve - glad we got there in the end. Try amending relevant bit to:
    Please Login or Register  to view this content.

  24. #24
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    stephen
    absolutely superb
    i cannot thank you enough
    is it possible for an explanation of how this code works~?
    if not i realise im pushing my luck

    many thanks
    steve

  25. #25
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    See if this helps. Excel Help is pretty good, and don't forget Google.
    Please Login or Register  to view this content.

  26. #26
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    superb stephen
    many thanks
    i will try take this on board
    its a lot better when its explained
    thank you very very much
    regards

+ 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