+ Reply to Thread
Results 1 to 9 of 9

Worksheet_Change Target Cell Contains a Formula

  1. #1
    Registered User
    Join Date
    04-16-2020
    Location
    Grand Rapids, MI
    MS-Off Ver
    15.0.5215.1000
    Posts
    12

    Worksheet_Change Target Cell Contains a Formula

    Hi!

    I have been struggling with a code for a few hours now. I am using this code to automatically hide or unhide rows based on the value in cell I7. The formula in cell I7 is =IFERROR(INDEX(AB2:AQ16,MATCH(C11,AA2:AA16,1),MATCH(I11,AB1:AQ1,0)),""). If the value is 5, I want a specific 5 rows to be available and other hidden. I cannot get the rows to automatically hide/unhide when that value changes. I am wondering if it is because there is a formula in the cell. If anyone has any insight on how to fix this I would really appreciate it!

    Here is what I have for the code:


    Please Login or Register  to view this content.
    Last edited by jmdk11; 04-16-2020 at 03:33 PM.

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Worksheet_Change Target Cell Contains a Formula

    Hello jmdk11,

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)Welcome to the forum

    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Registered User
    Join Date
    04-16-2020
    Location
    Grand Rapids, MI
    MS-Off Ver
    15.0.5215.1000
    Posts
    12

    Re: Worksheet_Change Target Cell Contains a Formula

    Got it, thank you!!

  4. #4
    Valued Forum Contributor
    Join Date
    08-03-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2007, 2010, 2013, 2016, Office 365
    Posts
    467

    Re: Worksheet_Change Target Cell Contains a Formula

    Hi

    perhaps you should use the Worksheet_Calculate() event???

    ..the Worksheet_Change event isn't triggered when a formula is re-calculated - it is triggered when, for example, a User manually changes the contents of cell(s) e.g. by editing a cell, pasting into a cell, deleting contents in a cell etc etc etc

    zeddy

  5. #5
    Registered User
    Join Date
    04-16-2020
    Location
    Grand Rapids, MI
    MS-Off Ver
    15.0.5215.1000
    Posts
    12

    Re: Worksheet_Change Target Cell Contains a Formula

    I thought about that too, but the main cell that would be changing is a different cell an AQL number is selected from a dropdown list, then the sample qty (I7) will automatically update. I need to reference I7 in the code, though, because that is the number that will determine how many rows are hidden. I am working on a sample workbook to attach. Thank you!

  6. #6
    Valued Forum Contributor
    Join Date
    08-03-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2007, 2010, 2013, 2016, Office 365
    Posts
    467

    Re: Worksheet_Change Target Cell Contains a Formula

    Hi

    Then use the change event to detect when the dropdown-cell has been changed, and then, if the drop-down cell has changed, then let the vba routine fetch the value from cell [i7] and proceed accordingly etc etc etc

    zeddy

  7. #7
    Valued Forum Contributor
    Join Date
    08-03-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2007, 2010, 2013, 2016, Office 365
    Posts
    467

    Re: Worksheet_Change Target Cell Contains a Formula

    Hi

    ..for example:
    Please Login or Register  to view this content.
    zeddy

  8. #8
    Registered User
    Join Date
    04-16-2020
    Location
    Grand Rapids, MI
    MS-Off Ver
    15.0.5215.1000
    Posts
    12

    Re: Worksheet_Change Target Cell Contains a Formula

    Perfect! I used the dropdown cell as the change even and used the following code and it worked (very similar to what you did). Thank you so much!

    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor
    Join Date
    08-03-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2007, 2010, 2013, 2016, Office 365
    Posts
    467
    Hi

    A simple and effective fix.
    Top marks.
    You did it yourself.
    Well done.
    Now just remember that for future use.

    zeddy

+ 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: 5
    Last Post: 12-16-2014, 05:47 PM
  2. [SOLVED] Worksheet_Change - If Target.Address = a cell reference
    By dredre609 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-02-2014, 12:04 PM
  3. [SOLVED] Worksheet_Change(ByVal Target As Range) - set to only update when 3 target cells changed?
    By trillium in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-07-2012, 06:40 PM
  4. Worksheet_CHange (ByVal Target as Range) when target is formula cell
    By coasterman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-09-2012, 07:00 PM
  5. Replies: 3
    Last Post: 11-15-2008, 03:32 PM
  6. Error when Target Range is block, not cell in Worksheet_Change Eve
    By Jim Zeeb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-11-2006, 03:20 PM
  7. Replies: 2
    Last Post: 06-19-2006, 12:10 PM

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