+ Reply to Thread
Results 1 to 8 of 8

copying cells to a new workbook

  1. #1
    Registered User
    Join Date
    04-13-2007
    Posts
    13

    copying cells to a new workbook

    Is it actually possible to copy the information in any selected cell into a brand new workbook? I just want to store a few key bits of information from lots of different people's spreadsheets in a quick referance guide but dont know how to copy them across to a new worksheet. I guess there is a key command after you select the wanted cells i.e copyto "bla bla" range etc.

    Many thanks,
    steve

  2. #2
    Forum Contributor boylejob's Avatar
    Join Date
    02-22-2007
    Location
    Forest City, NC
    MS-Off Ver
    2003
    Posts
    562
    Steve,

    Are you wanted to use VBA to accomplish this task. I move data from one spreadsheet to another all the time using VBA.

    I also believe you need to give some more details about your problem. Are you just wanting to gather random bits and pieces of information or are you gathering the same information off of different spreadsheets and then creating a type of master spreadsheet. A few more details will help folks better understand exactly what you are trying to accomplish.

    Jeff

  3. #3
    Registered User
    Join Date
    04-13-2007
    Posts
    13
    my apologies for unclear posting. Yes basically I want to write an extra line of code on a macro that operates automatically so that certain key datails are sent to a brand new spreadsheet.

    So at the moment the user looking at a blank sheet just presses ctrl+A to initiate the main macro, this runs a dialog box into which lots of details are entered.

    These details are then automatically transfered onto a spreadsheet that calculates various formulas. This spredsheet is automatiacally saved in mhtml format and then on deciding whether to print this out or not on a seperate dialog box the user is returned to the blank start page for the next person. I would like to lift some of the cells from the spreadsheet and put them in a new workbook i.e name, age, results etc so that it is possible to compare at a glance some of the details of the different subjects.

    Im just looking for that magic line of code where the copy destination into a different workbook is defined.

    Thanks,
    steve

  4. #4
    Forum Contributor boylejob's Avatar
    Join Date
    02-22-2007
    Location
    Forest City, NC
    MS-Off Ver
    2003
    Posts
    562
    Steve,

    This should give you some information to work with. You basically define two variables as worksheets and then assign the two sheets you are wanting to work with to these varibles. Then you can move data back and forth between the two.

    Below is some code that you can incorporate into what you are doing. Of course you will need to replace some of the generic names I am using with whatever you are working with.

    Please Login or Register  to view this content.
    Hope this can get you started.

    Jeff

  5. #5
    Registered User
    Join Date
    04-13-2007
    Posts
    13
    thanks alot for your help mate... appreciated.

    Unfortunately no dice, whatever I do I seem to get a run time error 9 message... it cannot find the destination workbook I have created even when I give the full directory... i.e Workbooks("H:\MyDocuments\GFR\log.xls").

    I dont understand it just refuses to look outside the actve workbook. Do I need to put this bit of code somewhere special or something?

    Cheers,
    Steve

  6. #6
    Forum Contributor boylejob's Avatar
    Join Date
    02-22-2007
    Location
    Forest City, NC
    MS-Off Ver
    2003
    Posts
    562
    Steve,

    Is the other workbook open. Although I have heard that you can move information into a workbook that is not open, I have yet to find anyone that knows how to do it. Therefore, I always make sure the workbooks I am needing to use are open.

    I use the statement below to see if a spreadsheet has been opened.



    Please Login or Register  to view this content.
    The above statement uses the following function to see if a file is open and if it is not, it will open it.

    Please Login or Register  to view this content.
    See if that helps at all. To give credit where credit is due, I believe John Walkenback wrote this function.

    Jeff

  7. #7
    Registered User
    Join Date
    04-13-2007
    Posts
    13
    Just thought I should say cheers and just give out the working code to anyone who needs it.
    I should just mention that I put this in the personal workbook as it can't seem to call out from workbook to another, but it works fine from there


    Please Login or Register  to view this content.

  8. #8
    Forum Contributor boylejob's Avatar
    Join Date
    02-22-2007
    Location
    Forest City, NC
    MS-Off Ver
    2003
    Posts
    562
    Steve,

    Glad it helped! I have mine in my Personal Workbook also. You just need to make sure each of your programs reference your Personal Workbook so they have access to the function.

    I am assuming your problem has been solved?
    Sincerely,
    Jeff

+ 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