Results 1 to 15 of 15

How do you get this event macro to work?

Threaded View

  1. #1
    Registered User
    Join Date
    03-01-2013
    Location
    Pittsburgh, Pennsylvania
    MS-Off Ver
    Excel 2010
    Posts
    6

    How do you get this event macro to work?

    This is a macro I found online to freeze the first tab in my workbook. I am new to VBA, so please explain in details.

    Private Sub Workbook_SheetActivate(ByVal Sh As Object)
        Dim sc As Long ' count of sheets
        Dim NewPos As Long ' index of serlected sheet
    
        Application.EnableEvents = False
        Application.ScreenUpdating = False
    
        If ActiveSheet.Index <> 1 Then
            sc = Sheets.Count
            NewPos = ActiveSheet.Index
            For i = 2 To NewPos - 1
                Sheets(2).Move After:=Sheets(sc)
            Next i
            Sheets(1).Activate
            Sheets(2).Activate
        End If
    
        Application.ScreenUpdating = True
        Application.EnableEvents = True
    End Sub
    Last edited by arlu1201; 03-02-2013 at 07:10 AM.

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