Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jan 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is there a way to make it so that a macro will automatically run when a specific spreadsheet is opened? Can someone please help me with this?

    I need the following macro to run every time a certain spreadsheet is opened. I'm sure there is a pretty simple way to do this, but....

    Option Explicit
    Public Function color cell (range As rank, color index As Integer)
    Dim cell As range
    For Each cell within rank
    If cell. Interior.ColorIndex = color index Then
    Color cell = color cell + 1
    End If
    NEXT
    End Function

  2. #2
    5 Star Lounger
    Join Date
    Aug 2004
    Location
    Connecticut, USA
    Posts
    816
    Thanks
    0
    Thanked 0 Times in 0 Posts
    To have a macro run when a workbook is opened

    Right click on one of the tabs in the workbook and choose View Code
    In the Project Window double click on ThisWorkbook for the current workbook . This will open the code module.
    Use the drop down above the code module, change it from "(General)" to "Workbook"
    If the other drop down above the code module does not show "Open", change the selection to "Open"
    Enter your code

  3. #3
    New Lounger
    Join Date
    Jan 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='mbarron' post='784932' date='16-Jul-2009 15:13']To have a macro run when a workbook is opened

    Right click on one of the tabs in the workbook and choose View Code
    In the Project Window double click on ThisWorkbook for the current workbook . This will open the code module.
    Use the drop down above the code module, change it from "(General)" to "Workbook"
    If the other drop down above the code module does not show "Open", change the selection to "Open"
    Enter your code[/quote]

    Thank you!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •