+ Reply to Thread
Results 1 to 11 of 11

Change destination workbook in macro

  1. #1
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    Change destination workbook in macro

    Hi,

    I am currently using a macro that works great but I would like to change the destination -

    Dim wsSource As Worksheet, wsDest As Worksheet
    Dim lastRow As Integer

    Set wsSource = ThisWorkbook.Sheets("RDBMergeSheet")
    Set wsDest = ThisWorkbook.Sheets("MasterData")

    I would like the destination to be a workbook that I will have open called "Volume Data".xlsm with the ws called "Master Data"

    Any help would be appreciated. Thanks in advance,

  2. #2
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: Change destination workbook in macro

    Try:
    Please Login or Register  to view this content.
    Change to your path in red
    Click the * to say thanks.

  3. #3
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    Re: Change destination workbook in macro

    Hi, Paul

    Thanks but it has a problem with Set WD...
    I have changed it to -

    Dim WD As Workbook
    Dim FP As String
    Dim wsSource As Worksheet, wsDest As Worksheet
    Dim lastRow As Integer

    FP = "G:\APP ZONE\BDs MASTERS\BD CPC\BD NEW\Volume Data" & "\"

    Set WD = Workbook.Open(FP & "Volume Data.xlsm")
    Set wsSource = ThisWorkbook.Sheets("RDBMergeSheet")
    Set wsDest = WD.Sheets("MasterData")

    Volume Data is also the name of the folder

  4. #4
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    Re: Change destination workbook in macro

    Is there a problem with my path?

  5. #5
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: Change destination workbook in macro

    Looks fine. What is the problem with Set WD?

  6. #6
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    Re: Change destination workbook in macro

    Hi. Thanks.
    When I run the macro I get a Run time error 424 and when I click Debug, the Set WD... is highlighted yellow

  7. #7
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: Change destination workbook in macro

    Oh, I forgot a letter. Change to this:
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    Re: Change destination workbook in macro

    hahaha. Closer. But Volume Data.xlsm is already open and that's where I am running the code from.
    Now it's telling me that Volume Data is already open and re-opening it will...

  9. #9
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: Change destination workbook in macro

    I would like the destination to be a workbook that I will have open called "Volume Data".xlsm with the ws called "Master Data"
    This is saying that you need the destination as another workbook. How you run the code from it, if is another workbook?

  10. #10
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    Re: Change destination workbook in macro

    I run the code in the wb called Volume Data which creates an RDBMergeSheet which then copies the new data into the MasterData sheet which was in the same wb.
    But the file is getting too big so I moved it into its own wb called wb called Raw Data with the ws named Master Data. I need the RDBMergeSheet data copied to that wb.
    Sorry for the confusion. I would make a terrible teacher. lol

  11. #11
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    Re: Change destination workbook in macro

    I think I have it. Thank you for pointing out that conflict. I made the following change - Set WD = Workbooks.Open(FP & "Raw Data.xlsm"). Exactly what I was looking for. Thank you for your patience and help!

+ 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. [SOLVED] How to copy from source workbook and pasting at first empty row in destination workbook
    By taylorsm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-29-2017, 10:20 AM
  2. Replies: 18
    Last Post: 10-08-2017, 04:17 AM
  3. Replies: 0
    Last Post: 07-21-2015, 02:35 AM
  4. Replies: 3
    Last Post: 07-11-2013, 03:01 AM
  5. Change Paste Destination in a Copy Macro
    By Akira181 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-22-2013, 10:47 AM
  6. Get data from source workbook and paste to destination in change format
    By farrukh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-03-2012, 01:47 AM
  7. Change pdf printout destination using vba macro
    By dietzj1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-15-2010, 01:47 PM

Tags for this Thread

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