+ Reply to Thread
Results 1 to 3 of 3

Applying same macro to all worksheets in workbook

  1. #1
    jsadd1@gmail.com
    Guest

    Applying same macro to all worksheets in workbook

    HI,

    I am trying to find an easy way to apply a macro that changes the
    absolute value of a couple of cells and changes some plot formatting to
    all sheets in a workbook. All sheets are the same and need the same
    macro applied to them, I have recorded the macro such that I can click
    on a worksheet and hit a keyboard command to execute this, but I have
    to individually select each worksheet and repeat this throughout, how
    can this be automated?

    Thanks,

    Josh


  2. #2
    Jezebel
    Guest

    Re: Applying same macro to all worksheets in workbook

    Rewrite the macro so it takes a worksheet as an argument. Then write a
    second macro that iterates your worksheets and passes them one at a time to
    your first macro.

    Dim pSheet as Excel.WorkSheet

    For each pSheet in ActiveWorkbook.Sheets
    MyMacro pSheet
    Next





    <jsadd1@gmail.com> wrote in message
    news:1129760086.668395.138990@g14g2000cwa.googlegroups.com...
    > HI,
    >
    > I am trying to find an easy way to apply a macro that changes the
    > absolute value of a couple of cells and changes some plot formatting to
    > all sheets in a workbook. All sheets are the same and need the same
    > macro applied to them, I have recorded the macro such that I can click
    > on a worksheet and hit a keyboard command to execute this, but I have
    > to individually select each worksheet and repeat this throughout, how
    > can this be automated?
    >
    > Thanks,
    >
    > Josh
    >




  3. #3
    Gary''s Student
    Guest

    RE: Applying same macro to all worksheets in workbook

    This macro moves through each worksheet in a workbook and sums the first cell:

    Sub Macro1()
    Dim w As Worksheet
    t = 0
    For Each w In Worksheets
    w.Activate
    t = t + Cells(1, 1)
    Next
    MsgBox (t)
    End Sub

    Adapt it to your needs
    --
    Gary's Student


    "jsadd1@gmail.com" wrote:

    > HI,
    >
    > I am trying to find an easy way to apply a macro that changes the
    > absolute value of a couple of cells and changes some plot formatting to
    > all sheets in a workbook. All sheets are the same and need the same
    > macro applied to them, I have recorded the macro such that I can click
    > on a worksheet and hit a keyboard command to execute this, but I have
    > to individually select each worksheet and repeat this throughout, how
    > can this be automated?
    >
    > Thanks,
    >
    > Josh
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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