Results 1 to 4 of 4

Run macro on specific sheets

Threaded View

  1. #2
    Valued Forum Contributor
    Join Date
    08-29-2011
    Location
    Mississauga, CANADA
    MS-Off Ver
    Excel 2010
    Posts
    503

    Re: Run macro on specific sheets

    Use this:

    Option Explicit
    
    Sub Format_Specific_Sheets()
    On Error GoTo ErrHandler:
    Dim Sheetlist As Variant
    Dim i As Integer
    Sheetlist = Array("Hoja1", "Sheet1", "Sheet3", "Sheet4", "Sheet5") 'Define sheet names, to format
    For i = LBound(Sheetlist) To UBound(Sheetlist)
    ' Your Code Goes Here
        Worksheets(Sheetlist(i)).Range("F4:I8").Font.Bold = True
    Next
    Exit Sub
    ErrHandler:
        If Err.Number = 9 Then 'Sheet does not exist
            MsgBox "No more sheets fullfill the criteria. All operations completed succesfully", vbInformation, "Done"
        Else
            MsgBox "Error " & Err.Number & " (" & Err.Description & ")", vbInformation, "Humm..."
            Exit Sub
        End If
    
    End Sub
    Last edited by Kelshaer; 08-16-2012 at 04:19 PM.
    Regards,
    Khaled Elshaer
    www.BIMcentre.com

    Remember To Do the Following....
    1. Thank those who have helped you by clicking the Star below their post.
    2. Mark your post SOLVED if it has been answered satisfactorily:
    • Select Thread Tools (on top of your 1st post)
    • Select Mark this thread as Solved

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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