+ Reply to Thread
Results 1 to 4 of 4

Macro to stop at a certain tab and does not go to the next one.

  1. #1

    Macro to stop at a certain tab and does not go to the next one.

    I have this macro . This calculates the formuals and copis it to all
    the 50 tabs in the workbook, but I want to stop it at the 50th tab
    because the 51th tab is the master data that i dont want to touch. here
    is the code. Please help me how to stop the macro from going ot the
    last tab.

    Sub 50sheets()
    Dim ws As Worksheet
    For Each ws In Worksheets
    With Worksheets(ws.Name)
    .Activate
    .Range("D8:O10").Select
    Selection.FillDown
    .Range("D8:O8").Select

    .Range("D14:O18").Select
    Selection.FillDown

    .Range("D22:O25").Select
    Selection.FillDown

    .Range("D29:O33").Select
    Selection.FillDown

    .Range("D39:O41").Select
    Selection.FillDown

    .Range("D50:O63").Select
    Selection.FillDown

    .Range("D80:O80").Select
    Selection.FillDown


    End With
    Next ws

    Worksheets("1").Activate

    End Sub


  2. #2
    Dave Peterson
    Guest

    Re: Macro to stop at a certain tab and does not go to the next one.

    I think I'd just ignore that master worksheet--then I wouldn't care where it was
    in the workbook.

    Sub 50sheets()
    Dim ws As Worksheet
    For Each ws In Worksheets
    with ws 'no need to get the name
    if lcase(ws.name) = lcase("master") then
    'do nothing
    else
    'do the work
    .Activate
    .Range("D8:O10").Select
    Selection.FillDown

    "[email protected]" wrote:
    >
    > I have this macro . This calculates the formuals and copis it to all
    > the 50 tabs in the workbook, but I want to stop it at the 50th tab
    > because the 51th tab is the master data that i dont want to touch. here
    > is the code. Please help me how to stop the macro from going ot the
    > last tab.
    >
    > Sub 50sheets()
    > Dim ws As Worksheet
    > For Each ws In Worksheets
    > With Worksheets(ws.Name)
    > .Activate
    > .Range("D8:O10").Select
    > Selection.FillDown
    > .Range("D8:O8").Select
    >
    > .Range("D14:O18").Select
    > Selection.FillDown
    >
    > .Range("D22:O25").Select
    > Selection.FillDown
    >
    > .Range("D29:O33").Select
    > Selection.FillDown
    >
    > .Range("D39:O41").Select
    > Selection.FillDown
    >
    > .Range("D50:O63").Select
    > Selection.FillDown
    >
    > .Range("D80:O80").Select
    > Selection.FillDown
    >
    > End With
    > Next ws
    >
    > Worksheets("1").Activate
    >
    > End Sub


    --

    Dave Peterson

  3. #3

    Re: Macro to stop at a certain tab and does not go to the next one.

    Hi Dave,
    This doesnt work. Can you explpain this more . I tried to use it but it
    crashed.

    Thanks


  4. #4
    Dave Peterson
    Guest

    Re: Macro to stop at a certain tab and does not go to the next one.

    I think you'll have to post the code you used.

    And did you change this line:

    if lcase(ws.name) = lcase("master") then

    To use the real name of your "master" worksheet--I guessed that its name was
    "master".

    "[email protected]" wrote:
    >
    > Hi Dave,
    > This doesnt work. Can you explpain this more . I tried to use it but it
    > crashed.
    >
    > Thanks


    --

    Dave Peterson

+ 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