Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Feb 2006
    Thanked 0 Times in 0 Posts

    IF then on filename (2003)

    On worksheet open, want to jump to section of code if filename does not match specific name.
    I have master worksheet with code that blanks specific cells when opened. Users open master, complete input, and then "save as" under different name to their desktop. When user re-opens their file, look at open filename and skip cell blanking if it does not match Master filename.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: IF then on filename (2003)

    You could do the following:
    - Press Alt+F11 to activate the Visual Basic Editor.
    - Double-click the ThisWorkbook item for the workbook in the Project Explorer on the left hand side.
    - Enter or copy/paste the following code:

    Private Sub Workbook_Open()
    If Not ThisWorkbook.Name = "SpecificName.xls" Then
    ' Code to blank cells here
    ' Or call a macro that does that
    End If
    End Sub

    Change the name to the one you want.
    However, this is not very secure: if the user doesn't enable macros when opening the workbook, the code will not run.

Posting Permissions

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