+ Reply to Thread
Results 1 to 7 of 7

Macro to copy Master sheet to all other sheets in workbook

  1. #1
    Forum Contributor
    Join Date
    12-18-2011
    Location
    long island
    MS-Off Ver
    365
    Posts
    236

    Macro to copy Master sheet to all other sheets in workbook

    I'm trying to write a macro that copies one sheet in my workbook (master) and pastes it to all other sheets in the workbook (excluding master). Fairly certain I need a loop but I'm not 100%.

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,206

    Re: Macro to copy Master sheet to all other sheets in workbook

    eg
    Please Login or Register  to view this content.
    Artik

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: Macro to copy Master sheet to all other sheets in workbook

    If all the sheets are empty and you just want values.
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    12-18-2011
    Location
    long island
    MS-Off Ver
    365
    Posts
    236

    Re: Macro to copy Master sheet to all other sheets in workbook

    This works. However, my master file contains a query. When I run this macro, I create a duplicate query (master (2)). Anyway to delete this second query but keep the formatting of the table (which is lost if pasting as values)?

  5. #5
    Forum Contributor
    Join Date
    12-18-2011
    Location
    long island
    MS-Off Ver
    365
    Posts
    236

    Re: Macro to copy Master sheet to all other sheets in workbook

    Alternativity, I have altered the code to paste values and then past formats to keep source formatting. I'd like to clear the sheet before pasting, so I inserted the following:
    Please Login or Register  to view this content.
    However, I'm now getting an error at:
    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,206

    Re: Macro to copy Master sheet to all other sheets in workbook

    There are some bugs here.
    Please Login or Register  to view this content.
    You are trying to select cell A1 in the worksheet (wks) under examination. Even if it is successful with one sheet, it will definitely cause an error in the next one. To select a cell on any worksheet, it must be active. The code does not show that you activate the sheet under test.

    But there is no need to activate the worksheet and select a cell to do the following:
    Please Login or Register  to view this content.
    For example, you can:
    Please Login or Register  to view this content.
    No activation, no selection, and rows are deleted.

    And we come to the problem of the error in the line:
    Please Login or Register  to view this content.
    Before the For Each ... Next loop, you are copying the range rng, but by executing a line that removes rows, the copy mode is canceled. And that's why you get an error.
    You will need in this loop to copy and paste the scope of the source into the worksheet you are examining.

    Artik

  7. #7
    Forum Contributor
    Join Date
    12-18-2011
    Location
    long island
    MS-Off Ver
    365
    Posts
    236

    Re: Macro to copy Master sheet to all other sheets in workbook

    That fixed it
    Thanks!

+ 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/paste from master sheet to other sheets
    By jw01 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-16-2016, 12:12 PM
  2. Replies: 1
    Last Post: 08-22-2015, 11:39 PM
  3. [SOLVED] Copy data from master sheet in workbook to monthly sheets
    By joserborges in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-27-2014, 09:24 PM
  4. Marcto to copy sheets from one workbook to a master sheet, for all files in folder
    By crombieguy91 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-14-2013, 11:12 AM
  5. Macro to apply a filter from one sheet (a master sheet) to all sheets in workbook
    By SeaniGeld in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-30-2013, 02:00 PM
  6. Help with Copy and Paste Macro from Master sheet to other sheets
    By Livetorace27 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-11-2013, 03:19 PM
  7. [SOLVED] Macro to copy data from multiple sheets to one (new) master sheet
    By nhtodd in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-24-2012, 02:30 AM

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