Results 1 to 3 of 3

How do I repeat a macro for each page without having to copy the macro for every page

Threaded View

dmccue How do I repeat a macro for... 10-03-2014, 05:55 AM
Pepe Le Mokko Re: How do I repeat a macro... 10-03-2014, 05:59 AM
dmccue Re: How do I repeat a macro... 10-07-2014, 09:44 PM
  1. #1
    Registered User
    Join Date
    12-30-2013
    Location
    Gold Coast Queensland
    MS-Off Ver
    Excel 2007
    Posts
    35

    How do I repeat a macro for each page without having to copy the macro for every page

    I have a spreadsheet that is 40 pages (can't attach) that spans across a 14day period with 1 sheet for each day
    The macro reads another sheet and fills in my daily sheet

    How do I write this so I can condense the actions rather than having to copy it for each day.

    This is what I have written for the 1st 2 days and it works ok but I would like to condense it
    GT MON WK1 is where the macro is reading from for 1st sheet
    GT TUE WK1 is the next day etc etc

    Any ideas?


    Range("C16:D16").Select
        ActiveCell.FormulaR1C1 = "='GT MON WK1'!R[38]C[1]"
        Range("C16:D16").Select
        Selection.AutoFill Destination:=Range("C16:D25"), Type:=xlFillDefault
        Range("C16:D25").Select
        Range("F16:G16").Select
        ActiveCell.FormulaR1C1 = "='DS MON WK1'!R[38]C[-1]"
        Range("F16:G16").Select
        Selection.AutoFill Destination:=Range("F16:G25"), Type:=xlFillDefault
        Range("F16:G25").Select
        Range("I16:J16").Select
        ActiveCell.FormulaR1C1 = "='GT MON WK1'!R[38]C[-3]"
        Range("I16:J16").Select
        Selection.AutoFill Destination:=Range("I16:J25"), Type:=xlFillDefault
        Range("I16:J25").Select
        Range("L16:M16").Select
        ActiveCell.FormulaR1C1 = "='GT MON WK1'!R[7]C[-8]"
        Range("L16:M16").Select
        Selection.AutoFill Destination:=Range("L16:M25"), Type:=xlFillDefault
        Range("L16:M25").Select
        Range("O16:P16").Select
        ActiveCell.FormulaR1C1 = "='GT MON WK1'!R[7]C[-10]"
        Range("O16:P16").Select
        Selection.AutoFill Destination:=Range("O16:P25"), Type:=xlFillDefault
        Range("O16:P25").Select
        Range("R16:S16").Select
        ActiveCell.FormulaR1C1 = "='GT MON WK1'!R[7]C[-12]"
        Range("R16:S16").Select
        Selection.AutoFill Destination:=Range("R16:S25"), Type:=xlFillDefault
        Range("R16:S25").Select
        Range("U16:V16").Select
        ActiveCell.FormulaR1C1 = "='GT MON WK1'!R[7]C[-14]"
        Range("U16:V16").Select
        Selection.AutoFill Destination:=Range("U16:V25"), Type:=xlFillDefault
        Range("U16:V25").Select
        Range("X16:Y16").Select
        ActiveCell.FormulaR1C1 = "='GT MON WK1'!R[7]C[-16]"
        Range("X16:Y16").Select
        Selection.AutoFill Destination:=Range("X16:Y25"), Type:=xlFillDefault
        Range("X16:Y25").Select
        Range("AA16:AB16").Select
        ActiveCell.FormulaR1C1 = "='GT MON WK1'!R[7]C[-18]"
        Range("AA16:AB16").Select
        Selection.AutoFill Destination:=Range("AA16:AB25"), Type:=xlFillDefault
        Range("AA16:AB25").Select
        Range("AA17").Activate
        Range("b7").Select
        
        Range("C16:D16").Select
        ActiveCell.FormulaR1C1 = "='GT tue WK1'!R[38]C[1]"
        Range("C16:D16").Select
        Selection.AutoFill Destination:=Range("C16:D25"), Type:=xlFillDefault
        Range("C16:D25").Select
        Range("F16:G16").Select
        ActiveCell.FormulaR1C1 = "='DS tue WK1'!R[38]C[-1]"
        Range("F16:G16").Select
        Selection.AutoFill Destination:=Range("F16:G25"), Type:=xlFillDefault
        Range("F16:G25").Select
        Range("I16:J16").Select
        ActiveCell.FormulaR1C1 = "='GT tue WK1'!R[38]C[-3]"
        Range("I16:J16").Select
        Selection.AutoFill Destination:=Range("I16:J25"), Type:=xlFillDefault
        Range("I16:J25").Select
        Range("L16:M16").Select
        ActiveCell.FormulaR1C1 = "='GT tue WK1'!R[7]C[-8]"
        Range("L16:M16").Select
        Selection.AutoFill Destination:=Range("L16:M25"), Type:=xlFillDefault
        Range("L16:M25").Select
        Range("O16:P16").Select
        ActiveCell.FormulaR1C1 = "='GT tue WK1'!R[7]C[-10]"
        Range("O16:P16").Select
        Selection.AutoFill Destination:=Range("O16:P25"), Type:=xlFillDefault
        Range("O16:P25").Select
        Range("R16:S16").Select
        ActiveCell.FormulaR1C1 = "='GT tue WK1'!R[7]C[-12]"
        Range("R16:S16").Select
        Selection.AutoFill Destination:=Range("R16:S25"), Type:=xlFillDefault
        Range("R16:S25").Select
        Range("U16:V16").Select
        ActiveCell.FormulaR1C1 = "='GT tue WK1'!R[7]C[-14]"
        Range("U16:V16").Select
        Selection.AutoFill Destination:=Range("U16:V25"), Type:=xlFillDefault
        Range("U16:V25").Select
        Range("X16:Y16").Select
        ActiveCell.FormulaR1C1 = "='GT tue WK1'!R[7]C[-16]"
        Range("X16:Y16").Select
        Selection.AutoFill Destination:=Range("X16:Y25"), Type:=xlFillDefault
        Range("X16:Y25").Select
        Range("AA16:AB16").Select
        ActiveCell.FormulaR1C1 = "='GT tue WK1'!R[7]C[-18]"
        Range("AA16:AB16").Select
        Selection.AutoFill Destination:=Range("AA16:AB25"), Type:=xlFillDefault
        Range("AA16:AB25").Select
        Range("AA17").Activate
        Range("b7").Select
    Last edited by dmccue; 10-03-2014 at 06:05 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA/Macro to detect a heading at the bottom of a page and create a page break
    By jdodz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-22-2014, 07:16 PM
  2. Macro to Repeat Rows at bottom of each Page
    By vamsidhar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-21-2013, 10:28 PM
  3. Hide Column & Print page Macro printing blank page?!
    By Margate in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-18-2013, 03:59 PM
  4. [SOLVED] Macro that copy page to page just some filled cells
    By LC in forum Excel General
    Replies: 0
    Last Post: 05-13-2005, 07:06 PM
  5. [SOLVED] Macro for Page Setup - Repeat rows at top
    By epuk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-01-2005, 12:06 AM

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