+ Reply to Thread
Results 1 to 7 of 7

how to make workbook open code specific to a sheet

  1. #1
    Registered User
    Join Date
    11-11-2014
    Location
    Cheltenham, England
    MS-Off Ver
    2010
    Posts
    19

    how to make workbook open code specific to a sheet

    I have the following piece of code that works with no problems when associated with a specific sheet Sheets("IAMT") however I would like to move this code to the Workbook_Open() function but I don't know how to bound this to reference the specific sheet.

    The code is as follows

    Please Login or Register  to view this content.
    help much appreciated
    Last edited by whitwoo; 12-18-2014 at 12:49 PM. Reason: Spelling!!

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: how to make workbook open code specific to a sheet

    Right click on your sheet name at the bottom of excel and select view code

    paste this into that module. [ All macros in that module are sheet specific ].

    [CODEPrivate Sub Worksheet_Activate()
    For Each Cll In Range("F3:FF3")
    If Cll.Value > DTPicker22.Value Or Cll.Value < DTPicker21.Value Then Cll.EntireColumn.Hidden = True Else Cll.EntireColumn.Hidden = False
    Next Cll
    Application.ScreenUpdating = True
    End Sub[/CODE]
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: how to make workbook open code specific to a sheet

    Maybe point the macro to the IAMT worksheet first?

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    11-11-2014
    Location
    Cheltenham, England
    MS-Off Ver
    2010
    Posts
    19

    Re: how to make workbook open code specific to a sheet

    I think you or I have miss understood - I want the code to run when opening the workbook so I think I need to place the code in the Workbook_Open() function.

    The same code also runs on the page and is ties to a datepicker change.

    I am a complete novice so I may be way off the mark

  5. #5
    Registered User
    Join Date
    11-11-2014
    Location
    Cheltenham, England
    MS-Off Ver
    2010
    Posts
    19

    Re: how to make workbook open code specific to a sheet

    JieJenn

    I tried your suggestion but got a 'Compile error: Sub of Function not defined' when I open the workbook

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: how to make workbook open code specific to a sheet

    Can you post your workbook?

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: how to make workbook open code specific to a sheet

    Is the code you posted located in the module of the worksheet the datepicker is on?
    If posting code please use code tags, see here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 11-28-2014, 06:28 AM
  2. [SOLVED] Macro to make the workbook open sheet 1
    By Oeysbrei in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-02-2012, 09:57 AM
  3. Master Sheet to Open Specific Sheet from a Separate Workbook
    By jennyaccord in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-14-2011, 10:40 AM
  4. Code to open workbook and change value in a specific cell
    By rhudgins in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 11-01-2010, 05:27 PM
  5. Replies: 9
    Last Post: 12-06-2005, 03:00 PM

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