+ Reply to Thread
Results 1 to 6 of 6

Copy cells to specific file using open dialogue box.

  1. #1
    Forum Contributor
    Join Date
    07-02-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    109

    Copy cells to specific file using open dialogue box.

    I have a workbook called “cost8.9” which as a macro that copies various cells from a sheet called “VCS” & pastes them into another workbook called “Price Build Up” on the sheet called “PBU”. The following code allows this to happen:

    Please Login or Register  to view this content.

    What I now want is a code that opens the “Open As” dialogue box in a default file path location & when I choose a specific file I want it to paste the cells into the choosen file as the above code?

    Hope that makes sense & someone can assist?
    Thanks,

    Tony.

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Copy cells to specific file using open dialogue box.

    Please Login or Register  to view this content.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Copy cells to specific file using open dialogue box.

    This version checks to see if the file is open before opening it, similar to the original version you had.

    However, to run it you will have to add a reference to the 'Microsoft Scripting Runtime' by going to Tools->References

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    07-02-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    109

    Re: Copy cells to specific file using open dialogue box.

    Fantastic thanks

    Could i just ask you when the VBA is run in both codes & i look at the workbook Price Build Up it shows the last sheet as default. I want it to show the first sheet i.e the one named PBU. Is this possible?

    Thanks again,

    Tony.

  5. #5
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Copy cells to specific file using open dialogue box.

    Are you referring to the sheet that is active when the workbook opens? It will be whatever sheet was active when the workbook was saved and closed. You can choose to activate one if you'd like. Maybe try:
    Please Login or Register  to view this content.
    After this:
    Please Login or Register  to view this content.
    On a side note, the variable WasOpen is dimmed correctly and set to True in the lines above but I don't see where it is ever used for anything. Is this from previous versions that isn't needed any more?

    Also, this code will probably get an error if there isn't a sheet name VDS in the workbook they choose to open.

  6. #6
    Forum Contributor
    Join Date
    07-02-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    109

    Re: Copy cells to specific file using open dialogue box.

    Thank you. I placed the PBwb.Sheets(1).activate as follows & it worked great.

    Please Login or Register  to view this content.
    Regarding the variable WasOpen i am not sure it may be from a previous version.

    There will always be a sheet named VDS so we will be ok.

    Thanks again.

    Tony

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA/Macro Code needed to open 'Save As' dialogue box and set the file type to CSV
    By daleski in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-24-2013, 12:58 PM
  2. [SOLVED] Open specific folder, select file to open and copy then paste
    By Kranky in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-22-2012, 12:14 AM
  3. Selecting Default Folder in Open File Dialogue Box Problem
    By PaulC in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-08-2010, 04:25 PM
  4. VBA Cancelling the Open File Dialogue
    By Mase123y in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-20-2009, 01:37 PM
  5. Sort order in File Open dialogue box
    By Roberto in forum Excel General
    Replies: 1
    Last Post: 12-11-2005, 08:50 PM

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