+ Reply to Thread
Results 1 to 3 of 3

Specifying a sheet & range in ThisWorkbook module

  1. #1
    Registered User
    Join Date
    10-27-2012
    Location
    Uk
    MS-Off Ver
    Excel 2010
    Posts
    98

    Question Specifying a sheet & range in ThisWorkbook module

    Hi All,

    I'm sure this is really simple but I just can't figure out what's wrong
    I have a small piece of code in the 'ThisWorkbook' module that changes a specific cell from FALSE/TRUE whenever the workbook is saved

    Please Login or Register  to view this content.
    Unfortunately this code executes on whichever sheet I am on at the time
    How can I specify which sheet this should run on?

    I've tried the following

    Please Login or Register  to view this content.
    But this gives "Runtime error 1004 - select method of range class failed"

    And also

    Please Login or Register  to view this content.
    But this still executes on the active sheet rather than sheet4 ("INV & CRN")

    Any help would be appreciated
    Kind regards
    V

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Specifying a sheet & range in ThisWorkbook module

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    10-27-2012
    Location
    Uk
    MS-Off Ver
    Excel 2010
    Posts
    98

    Re: Specifying a sheet & range in ThisWorkbook module

    That works perfectly! Thank you so much

+ 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. Difference between sheet, module and thisworkbook in excel
    By elfor in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-01-2017, 09:50 AM
  2. ThisWorkbook Module Add-in
    By asalamun in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-27-2017, 01:04 PM
  3. [SOLVED] Can't reference ThisWorkbook from a module in another workbook module
    By Bukovnik in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-11-2015, 11:32 AM
  4. Replies: 1
    Last Post: 08-30-2011, 02:23 AM
  5. Problem with ThisWorkbook Module
    By docnadir in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-12-2011, 12:02 PM
  6. [SOLVED] Calls from sheet module to ThisWorkbook module
    By quartz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-23-2005, 11:05 AM
  7. Sheet turns into a "ThisWorkbook" module
    By Rob in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-15-2005, 10:06 AM

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