+ Reply to Thread
Results 1 to 2 of 2

Copy/Paste Sheet to Another Workbook Not Working

  1. #1
    Registered User
    Join Date
    05-04-2020
    Location
    San Diego, CA
    MS-Off Ver
    Office 2016
    Posts
    1

    Question Copy/Paste Sheet to Another Workbook Not Working

    Hi everyone,

    I am having an issue that I can't seem to fix. I tried looking everywhere for a solution, but all the code I found matched the code I already had. I think I know where the code is breaking down, but unsure why. My destination workbook opens, but the sheet does not copy. I am trying to copying a worksheet to another user specified workbook. The worksheet does contain formulas that will need to be pasted as values on the specified workbook so if a solution to that could be provided that would be much appreciated. My code is below.

    Sub ExportComparison()
    Application.ScreenUpdating = False

    Dim Fname As String
    Dim SrcSht As Worksheet
    Dim DestWbk As Workbook

    'Sheet that contains comparison
    Set SrcSht = ThisWorkbook.Sheets("HMO Comparisons")

    'Dialog box opens to select file where sheet will be copied to
    Fname = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls*), *.xls*", Title:="Select RFP to copy comparison to...")
    If Fname = "False" Then Exit Sub

    Set DestWbk = Workbooks.Open(Fname)
    'Copy and paste sheet from Comparison Tool to RFP
    SrcSht.Copy After:=DestWbk.Sheets(DestWbk.Sheets.Count)
    DestWbk.Close True

    Application.ScreenUpdating = True
    End Sub
    Last edited by bishop14; 05-12-2020 at 03:56 PM. Reason: Specifying I already searched for solutions

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Copy/Paste Sheet to Another Workbook Not Working

    Your code worked fine for me.

    BTW, read forum rule #2.

+ 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. Copy paste data from working files to new workbook for each customer
    By momoo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-16-2018, 03:57 PM
  2. Copy and Paste from one workbook to another not working
    By darkyam in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-06-2018, 04:20 PM
  3. Paste not working, but only in one sheet of workbook.
    By Befuddled in forum Excel General
    Replies: 2
    Last Post: 05-08-2015, 07:41 AM
  4. [SOLVED] Help! Copy row from one workbook and paste into last row of another workbook not working
    By Jo2710 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-18-2014, 05:24 PM
  5. Replies: 6
    Last Post: 03-26-2014, 11:40 PM
  6. [SOLVED] Open new workbook, copy and paste not working
    By cheeze83 in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 11-21-2013, 04:55 AM
  7. Simple Open Workbook, Copy Sheet, Paste In New Workbook Question
    By alulla in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-19-2013, 02:10 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