+ Reply to Thread
Results 1 to 5 of 5

Using a Target.Value expression when the referenced cell value is generated from a formula

  1. #1
    Registered User
    Join Date
    12-20-2016
    Location
    United States
    MS-Off Ver
    2016
    Posts
    40

    Using a Target.Value expression when the referenced cell value is generated from a formula

    Good morning/afternoon/evening everyone! Something I ran into today that I've searched the depths of the web to find a solution to, with no luck, is that I have a formula in many rows of Column "I" of a worksheet. The formula in each cell within Column I looks at the values of the corresponding cell in Columns A, F, G, and H to determine a "Yes" or "No" value. If the formula generates a "Yes" then great-- I don't need to do anything. However, if the formula generates a "No", then I need to automatically change the value of the corresponding cell in Column "R" to "Disabled".

    Here is the VBA that I started with:

    Please Login or Register  to view this content.
    The above code works perfectly if I manually enter "No" in Column I. I've used this same code for many years for data that is manually entered. But I've tried a slew of suggestions I've found across other people trying to accomplish this same thing as me today (using a formula), and can't find an answer that works for me. This is also just a small sample of data.... I have a few hundred rows of data to maintain, so this is why I rely on a formula in Column I.... manual text entry in Column I is really not an option.

    Does anyone know how I can accomplish using a "No" in Column I that has been generated by a formula, to then generate the string "Disabled" in the corresponding cell in Column R? I have an example file here:

    TestFile.xlsm

    Thanks so much!!!!!!!!!!!!!!!!

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,832

    Re: Using a Target.Value expression when the referenced cell value is generated from a for

    A change event is triggered whenever an edit is made to the spreadsheet, like manually entering "no" in a cell. When a change event is triggered, the "target" argument references the cell or range that was edited (but does not note any of the cells that are dependent on the change through formulas). If you are going to perform this task in a change event, you either need to drop the "If Target.Column = 9 ..." block If condition so that the task will be performed on any change, or identify the actual range you expect to edit that would trigger recalculation of column I (I notice that the current formula references column A, F, G, and H). Or maybe this task needs to be part of a calculate event rather than a change event.

    Is there a reason you are using an event procedure for this? It seems like a properly programmed formula in column R should be able to choose what to put in R. Something that includes IF(I5="No","Disabled","Enabled or Pending"). Perhaps it is just my tendency to shy away from VBA, but this seems like a task that would be easier to do in a worksheet formula than with a VBA event procedure.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    12-20-2016
    Location
    United States
    MS-Off Ver
    2016
    Posts
    40

    Re: Using a Target.Value expression when the referenced cell value is generated from a for

    Thanks for the assistance MrShorty! So unfortunately if I remove the "If Target.Column = 9" statement out, it would impact other columns that have a "No" as a result. I apologize that my sample worksheet I attached doesn't reflect that, I wasn't sure how much sample info I'd have to provide that was relevant to my actual worksheet, but I'll definitely do better on that next time

    The only problem with using a formula in Column I is that this column has data validation on my actual worksheet, forcing the end-use to select from a drop-down list. So I want the end-user to be able to manually choose from that drop-down list as they manually change the status, because the other options in the list cannot be automatically decided by a formula. Basically, a "Yes" in Column I could be a "Pending", "Enabled", OR "Removed" status in Column R, but the end-user would have to manually adjust that status using their first-hand knowledge. I guess there's really not an easy way to decide if a user meets the requirements (based on columns F, G, H) but has to be Removed because the user is no longer employed here, for instance. The only definitive is if the user should be in Disabled status.

    Hope that makes sense, and totally understand shying away from VBA. I was intimidated about for a while (not suggesting you are), but when I learned there were certain things I wanted to automate and formulas weren't always capable, I started dabbling with VBA and it's pretty enjoyable. I do formulas where I can, but VBA can really do some powerful stuff

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,922

    Re: Using a Target.Value expression when the referenced cell value is generated from a for

    Per MrShorty's suggestion, you can monitor A and F:H thus:

    Please Login or Register  to view this content.
    Rory

  5. #5
    Registered User
    Join Date
    12-20-2016
    Location
    United States
    MS-Off Ver
    2016
    Posts
    40

    Re: Using a Target.Value expression when the referenced cell value is generated from a for

    Thanks so much for the assistance Rory, and my apologies to both you and MrShorty...... sounds as if I misunderstood how to implement what was being suggested. However, your code that you provided worked like an absolute charm Rory. I really appreciate the assistance from both of you!

+ 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: 04-29-2021, 12:48 AM
  2. If initials are generated in a cell then a permanent date stamp is generated
    By pageandrewr1 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-08-2016, 12:15 PM
  3. [SOLVED] Formula to return Blank cell if referenced cell has no entries, if not use formula
    By stpeter in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-17-2016, 01:41 PM
  4. Replies: 5
    Last Post: 05-07-2013, 08:34 AM
  5. Replies: 5
    Last Post: 01-22-2013, 11:38 AM
  6. 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
  7. [SOLVED] Go to cell referenced in a formula
    By Dennis in forum Excel General
    Replies: 6
    Last Post: 05-30-2006, 04:35 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