+ Reply to Thread
Results 1 to 3 of 3

Modify a Macro to Repeat for all Selected Worksheets

  1. #1
    carl
    Guest

    Modify a Macro to Repeat for all Selected Worksheets

    I use this macro to help name ranges.

    Sub maketable()

    Range("B19").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select

    ActiveWorkbook.Names.Add Name:=Application.InputBox("Enter Table Name")

    End Sub


    Is it possible to modify it so that it will run on all selected worksheets
    (I select the worksheet via ctrl left click.

    Thank you in advance.

  2. #2
    John Michl
    Guest

    Re: Modify a Macro to Repeat for all Selected Worksheets

    This should do the trick. - John Michl

    Sub maketable()
    Set SheetList = ActiveWindow.SelectedSheets

    For Each sh In SheetList
    sh.Activate
    Range("B19").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select

    ActiveWorkbook.Names.Add Name:=Application.InputBox("Enter Table
    Name")
    Next sh

    End Sub


  3. #3
    John Michl
    Guest

    Re: Modify a Macro to Repeat for all Selected Worksheets

    Forgot to mention that in the future, post macro questions in the
    "programming" group since that's where the VBA pros hang out.

    - John


+ 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