+ Reply to Thread
Results 1 to 8 of 8

VBA Help - Code referencing another sheet

  1. #1
    Registered User
    Join Date
    12-01-2017
    Location
    Seattle
    MS-Off Ver
    2013
    Posts
    8

    VBA Help - Code referencing another sheet

    I'm super new to VBA. I am trying to write something that hides and unhides rows based on Country.

    Right now it's referencing cell A1. If I manually type "U.S." or "Canada" the Macro works; however, if I have cell A1 referencing cell B3 from my "Inputs" tab then it breaks. Is there a way to get a linked cell to work? HELP!

    Please Login or Register  to view this content.
    Last edited by jeffreybrown; 09-23-2019 at 06:02 PM. Reason: Please use code tags!

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA Help - Code referencing another sheet

    Sub Worksheet_Change is an event macro fired when a cell is changed in the sheet where this macro is.
    If you want a cell in sheet "Inputs" to launch the macro, put a copy of this macro in sheet "inputs".
    Or put your code in a module and in each sheet to fire the macro in Sub Worksheet_Change call the macro in the module
    - Battle without fear gives no glory - Just try

  3. #3
    Registered User
    Join Date
    12-01-2017
    Location
    Seattle
    MS-Off Ver
    2013
    Posts
    8

    Re: VBA Help - Code referencing another sheet

    Thanks but I'm still a bit confused. Do I use the same code and just put it in a module? Doesn't seem to work.

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA Help - Code referencing another sheet

    You know what ... attach a file

  5. #5
    Registered User
    Join Date
    12-01-2017
    Location
    Seattle
    MS-Off Ver
    2013
    Posts
    8

    Re: VBA Help - Code referencing another sheet

    Thank you!
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA Help - Code referencing another sheet

    Can confirm if my understanding is correct.
    What you want is according to the selection done in sheet "Inputs" in cell B3, trigger a macro to hide some rows in sheet "Template" according to the value in sheet "Inputs" cell B3
    To do that the macro doing the job is today hosted in procedure Worksheet_Change in sheet "Template"
    Is it ?

  7. #7
    Registered User
    Join Date
    12-01-2017
    Location
    Seattle
    MS-Off Ver
    2013
    Posts
    8

    Re: VBA Help - Code referencing another sheet

    Correct, I want to be able to change the input in the Inputs tab for B3 and have it trigger the macro on the Templates Tab. I don't care where the macro is hosted as long as it works.

  8. #8
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA Help - Code referencing another sheet

    A possibility can be
    in sheet Inputs 's code
    Please Login or Register  to view this content.
    in a module

    Please Login or Register  to view this content.

+ 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. Sheet Reference Problem, Formula suddenly referencing wrong sheet
    By Matt97NeedsHelp in forum Excel General
    Replies: 2
    Last Post: 07-11-2017, 10:16 AM
  2. [SOLVED] Referencing Sheet Code name
    By rjnc in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-22-2015, 09:08 AM
  3. Replies: 0
    Last Post: 01-09-2013, 06:58 AM
  4. Referencing original sheet to copy/paste into new sheet without using file name
    By pgarakani in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-24-2012, 02:06 PM
  5. Optimizing the Vlookup code in VB. Repitive code with different referencing range.
    By raknahs in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-23-2010, 05:03 PM
  6. referencing different sheet in code
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-11-2008, 11:29 AM
  7. [SOLVED] Referencing code outside of current sheet
    By nemadrias in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-29-2006, 03:30 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