Quantcast
Channel: Excel IT Pro Discussions forum
Viewing all articles
Browse latest Browse all 11829

Macro to copy data onto every sheet within workbook

$
0
0

I've created a macro that:

- unhides a sheet

- copies a named range

- hides the sheet

- pastes the data into A1 of the remaining sheets.

The macro works well but what if I add a new sheet - is there a piece of code that will run the macro on every sheet within the workbook. Ideally I would also want the macro to run from the currently selected sheet and apply to all sheets on the right (the macro would not effect any sheets on the left of the selected one).

Here is the code so far:

Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+Shift+Q
'
    Sheets("John").Select
    Sheets("Template").Visible = True
    Application.Goto Reference:="Data"
    Selection.Copy
    Sheets("Template").Select
    ActiveWindow.SelectedSheets.Visible = False
    Application.Goto Reference:="R1C1"
    ActiveSheet.Paste
    Sheets("Dave").Select
    Application.Goto Reference:="R1C1"
    ActiveSheet.Paste
    Sheets("Mike").Select
    Application.Goto Reference:="R1C1"
    ActiveSheet.Paste
End Sub


Viewing all articles
Browse latest Browse all 11829

Trending Articles