+ Reply to Thread
Results 1 to 5 of 5

Faster way of VBA to copy worksheet to new workbook

  1. #1
    Registered User
    Join Date
    09-11-2024
    Location
    Manila, Philippines
    MS-Off Ver
    Microsoft 365
    Posts
    3

    Post Faster way of VBA to copy worksheet to new workbook

    Is there a faster way to copy worksheet to new workbook using the VBA code below as reference? I only need to copy specific sheets to a new workbook and then remove all workbook links. Thank you in advance.


    Sub ExtractTaxAnnualizationCopy()

    If Sheets("EID_Tax Calculator").Range("C2").Value = 0 Then

    'Copy specific sheets only
    Worksheets(Array("Tax Annualization Copy", "13th Month Pay Copy", "EstimatedTaxableIncome Copy")).Copy

    Else

    Worksheets(Array("Tax Annualization Copy", "YTD Copy", "Pivot YTD Static Copy", "13th Month Pay Copy", "EstimatedTaxableIncome Copy")).Copy

    End If

    'Remove workbook links
    Dim ar As Variant
    Dim i As Integer

    ar = ActiveWorkbook.LinkSources(1)

    On Error Resume Next 'Trap error

    For i = 1 To UBound(ar) 'Excel VBA loop throuh links
    ActiveWorkbook.BreakLink ar(i), xlLinkTypeExcelLinks
    Next i

    On Error GoTo 0


    End Sub

  2. #2
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    3,050

    Re: Faster way of VBA to copy worksheet to new workbook

    Does it help if you disable calculation and screen updating?
    NB: On Error Resume Next is ignoring any errors, not trapping them.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-11-2024
    Location
    Manila, Philippines
    MS-Off Ver
    Microsoft 365
    Posts
    3

    Re: Faster way of VBA to copy worksheet to new workbook

    This made the macro run faster. Thank you!

  4. #4
    Registered User
    Join Date
    09-11-2024
    Location
    Manila, Philippines
    MS-Off Ver
    Microsoft 365
    Posts
    3

    Re: Faster way of VBA to copy worksheet to new workbook

    Quote Originally Posted by ByteMarks View Post
    Does it help if you disable calculation and screen updating?
    NB: On Error Resume Next is ignoring any errors, not trapping them.

    Please Login or Register  to view this content.
    Big help, thank you!

  5. #5
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    3,050

    Re: Faster way of VBA to copy worksheet to new workbook

    You're welcome

+ 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] Copy data from selected sheet of multiple workbook & copy in master worksheet of workbook
    By sanjuss2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-24-2021, 12:16 PM
  2. Faster way to copy data from MS Access to a worksheet
    By Jan7219 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-11-2020, 01:02 AM
  3. Open 2nd workbook find matching worksheet names and copy values to 1st workbook
    By Groovicles in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-09-2017, 10:22 AM
  4. Copy Worksheet Values/Formatting from closed workbook to open workbook
    By pchalk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-03-2016, 11:30 AM
  5. Replies: 5
    Last Post: 09-25-2015, 10:32 AM
  6. Macro: Copy from one workbook worksheet to a different workbook worksheet
    By Virgil Beach in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-06-2012, 01:13 AM
  7. Can't copy cells from Worksheet A in Workbook 1 to Worksheet B in Workbook 2
    By exartizo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-11-2005, 05:52 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