+ Reply to Thread
Results 1 to 4 of 4

macro help to copy all sheets

  1. #1
    Registered User
    Join Date
    09-27-2015
    Location
    BEIRUT
    MS-Off Ver
    2021
    Posts
    87

    macro help to copy all sheets

    Hello,
    please i need your help

    how to make this macro copy all sheets not only Sheet1

    Sub CopySheetToMultipleWorkbooks()
    Dim SourceSheet As Worksheet
    Dim FileDialog As FileDialog
    Dim FileName As Variant
    Dim TargetWorkbook As Workbook

    ' Set the source sheet
    Set SourceSheet = ThisWorkbook.Sheets("Sheet1") ' <-- Change to your sheet name

    ' Open file dialog to select workbooks
    Set FileDialog = Application.FileDialog(msoFileDialogFilePicker)
    With FileDialog
    .AllowMultiSelect = True
    .Title = "Select Workbooks to Copy Sheet To"
    .Filters.Add "Excel Files", "*.xls; *.xlsx; *.xlsm", 1
    If .Show <> -1 Then Exit Sub ' If user cancels
    For Each FileName In .SelectedItems
    Set TargetWorkbook = Workbooks.Open(FileName)

    ' Copy the sheet to the end
    SourceSheet.Copy After:=TargetWorkbook.Sheets(TargetWorkbook.Sheets.Count)

    ' Optional: Save & close
    TargetWorkbook.Save
    TargetWorkbook.Close
    Next FileName
    End With

    MsgBox "Sheet copied to all selected workbooks!", vbInformation
    End Sub

    Book1.xlsx

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,471

    Re: macro help to copy all sheets

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-27-2015
    Location
    BEIRUT
    MS-Off Ver
    2021
    Posts
    87

    Re: macro help to copy all sheets

    Thank You so much Logit !!
    Your solution works perfectly 👍☺️

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,471

    Re: macro help to copy all sheets

    You are 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] Macro to copy sheets from source data where the sheets are the same
    By Howardc1001 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-07-2023, 05:57 AM
  2. [SOLVED] Macro to Copy to other Sheets
    By Vincent.Eymard in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-12-2017, 05:17 AM
  3. [SOLVED] Macro to copy cell width to new sheets (ie copy original sheet format)
    By teenyjem in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-20-2013, 07:28 AM
  4. Macro that will copy from one cell across all sheets except for three sheets.
    By glide2131 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-07-2013, 09:49 PM
  5. macro to copy info to other tab-sheets, then print those sheets
    By zatarra in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-29-2012, 08:02 PM
  6. Macro to copy sheets
    By FGOMEZ in forum Excel General
    Replies: 1
    Last Post: 07-15-2005, 02:05 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