+ Reply to Thread
Results 1 to 6 of 6

run a macro for all sheets

  1. #1
    Bwoods
    Guest

    run a macro for all sheets

    I recorded a macro that i use to format a sheet. I would like to use this
    same macro on multiple sheets without having to select each one and then
    running the macro.

    thanks in advance

  2. #2
    Paul B
    Guest

    Re: run a macro for all sheets

    Bwoods, use something like this,

    Sub Test()
    Dim ws As Worksheet
    For Each ws In Worksheets
    With ws

    'Change to your code
    .Range("A1").Interior.ColorIndex = 6

    End With
    Next ws
    End Sub


    --
    Paul B
    Always backup your data before trying something new
    Please post any response to the newsgroups so others can benefit from it
    Feedback on answers is always appreciated!
    Using Excel 2002 & 2003

    "Bwoods" <[email protected]> wrote in message
    news:[email protected]...
    > I recorded a macro that i use to format a sheet. I would like to use this
    > same macro on multiple sheets without having to select each one and then
    > running the macro.
    >
    > thanks in advance




  3. #3
    L. Howard Kittle
    Guest

    Re: run a macro for all sheets

    Here's a loop I got from Tom O. just yesterday

    Sub CodeForEachSheet()
    Dim WS_Count As Integer
    Dim I As Integer

    WS_Count = ActiveWorkbook.Worksheets.Count
    Application.ScreenUpdating = False
    For I = 1 To WS_Count
    Worksheets(I).Activate

    ' Your code here

    Next I
    Worksheets(1).Activate
    Application.ScreenUpdating = True
    End Sub

    HTH
    Regard,
    Howard

    "Bwoods" <[email protected]> wrote in message
    news:[email protected]...
    >I recorded a macro that i use to format a sheet. I would like to use this
    > same macro on multiple sheets without having to select each one and then
    > running the macro.
    >
    > thanks in advance




  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

  5. #5
    Bwoods
    Guest

    Re: run a macro for all sheets

    That did the TRICK!!!! This will save me a ton of time!

    "L. Howard Kittle" wrote:

    > Here's a loop I got from Tom O. just yesterday
    >
    > Sub CodeForEachSheet()
    > Dim WS_Count As Integer
    > Dim I As Integer
    >
    > WS_Count = ActiveWorkbook.Worksheets.Count
    > Application.ScreenUpdating = False
    > For I = 1 To WS_Count
    > Worksheets(I).Activate
    >
    > ' Your code here
    >
    > Next I
    > Worksheets(1).Activate
    > Application.ScreenUpdating = True
    > End Sub
    >
    > HTH
    > Regard,
    > Howard
    >
    > "Bwoods" <[email protected]> wrote in message
    > news:[email protected]...
    > >I recorded a macro that i use to format a sheet. I would like to use this
    > > same macro on multiple sheets without having to select each one and then
    > > running the macro.
    > >
    > > thanks in advance

    >
    >
    >


  6. #6
    Tom Ogilvy
    Guest

    Re: run a macro for all sheets

    Didn't see anything pertinent to the questions asked. Sure you posted this
    in the correct thread. Unless you meant run it on each sheet manually which
    the OP said he/she didn't want to do.

    --
    Regards,
    Tom Ogilvy


    "davesexcel" <[email protected]> wrote
    in message news:[email protected]...
    >
    > http://tinyurl.com/r6mfz
    >
    > and
    >
    > http://tinyurl.com/mpq2d
    >
    > These are the answers for you
    >
    >
    > --
    > davesexcel
    > ------------------------------------------------------------------------
    > davesexcel's Profile:

    http://www.excelforum.com/member.php...o&userid=31708
    > View this thread: http://www.excelforum.com/showthread...hreadid=524090
    >




+ 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