+ Reply to Thread
Results 1 to 13 of 13

Update cell based on several criteria using VBA

  1. #1
    Forum Contributor
    Join Date
    08-15-2006
    Location
    USA
    MS-Off Ver
    Office 365, 64 bit
    Posts
    362

    Update cell based on several criteria using VBA

    I tried under the formula forum and it was suggested that the best solution would be VBA... so I'm going to try here...

    I'm trying to automate a column for the users where a "Type" is updated based on the criterion below... This would really save them a lot of time as they deal with over 200 rows per file and they update the type per each manually - this is daily as its changes frequently... please refer to the attachment

    Criteria:
    IF columns E or F have a total greater than $0, enter MDE in the corresponding row in column D
    IF column D already has MDE in the cell because columns E or F calculated 1st to update it, and any column from G - N has a total less than or greater than $0, leave as MDE
    IF column D has no MDE because columns E or F equals to $0, than update as CR if row 4 has a CR number (the CR number is unique)
    IF column D has no MDE because columns E or F equals to $0, than update as Other if row 4 has an Other (Other may appear more than 1 time)
    If any of the columns have $0 and row 4 is empty (in this case J - N, do nothing


    Note: columns E or F need to be precede the calculation (be calculated 1st) for column D before the other 4...
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: Update cell based on several criteria using VBA

    For your second criteria, what would the other option be (e.g. "D" already contains MDE, but all of the other columns are 0)?

  3. #3
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: Update cell based on several criteria using VBA

    Also what you you mean by
    IF column D has no MDE because columns E or F equals to $0, than update as CR if row 4 has a CR number (the CR number is unique)
    IF column D has no MDE because columns E or F equals to $0, than update as Other if row 4 has an Other (Other may appear more than 1 time)
    Doesn't your row 4 contain "Other" as well as 2 CR Numbers?

  4. #4
    Forum Contributor
    Join Date
    08-15-2006
    Location
    USA
    MS-Off Ver
    Office 365, 64 bit
    Posts
    362

    Re: Update cell based on several criteria using VBA

    Daniel-

    To answer your question, if it's already MDE (which we need to identify the MDE 1st BEFORE the CRs and Others), do nothing... In addition, the goal is to update column D with either MDE, CR or Other as that's how we identify whether the application was identified in the initial estimate (MDE), via a Change Request (CR) which comes after an MDE or Other - which also comes after an MDE...

    Thanks
    Last edited by rz6657; 07-24-2017 at 04:41 PM.

  5. #5
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: Update cell based on several criteria using VBA

    I understand the goal is to update column "D", and how you can update it based on the values in columns "E" and "F" in the same row (e.g. criteria 1). What is confusing me is how you would update a cell in column "D" based on what is in row 4 (do you search through all of row 4? Do you look at the heading of row 4 for the non-blank entry in the row of interest?).

  6. #6
    Forum Contributor
    Join Date
    08-15-2006
    Location
    USA
    MS-Off Ver
    Office 365, 64 bit
    Posts
    362

    Re: Update cell based on several criteria using VBA

    Since the code will 1st look at columns E or F and the each respective column has a total greater than $0, it will enter MDE in column D in those rows. Next, it will scan row 4 and column G is next. If that is a numerical (a CR number), than on that column if there are total less / greater than $0, enter CR in column D only on empty cells, those that do not have an MDE already populated. However, if when it scans row 4 and it's Other, do the same... that same will continue thru column N. From G - N, row for will either have a CR# or Other... hope this clarifies my goal...thx

  7. #7
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: Update cell based on several criteria using VBA

    If I'm understanding you correctly, this should do what you're asking.
    Please Login or Register  to view this content.
    My last question: I simply ignored your last criteria, as it is not currently affecting the code. However, is it possible that in your data you have a situation where row 4 is blank but not all the values in the column are 0? And if yes, what should the outcome be in that situation?

  8. #8
    Forum Contributor
    Join Date
    08-15-2006
    Location
    USA
    MS-Off Ver
    Office 365, 64 bit
    Posts
    362

    Re: Update cell based on several criteria using VBA

    Daniel -
    No, that situation will and should not happen... I did however, forget one more "DDE". I would think it's would I would just copy the from "Next i" to "End if", correct? thx

  9. #9
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: Update cell based on several criteria using VBA

    That's correct just like this
    Please Login or Register  to view this content.

  10. #10
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: Update cell based on several criteria using VBA

    Also, it seems like MDE is "Priority #1" (you will not change this status no matter what). Is it possible you will have values in multiple other headings (e.g. Other AND CR)? If so, is there a priority system for these?

  11. #11
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: Update cell based on several criteria using VBA

    Oops just realized this was supposed to change column D not C. Use this instead.
    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    08-15-2006
    Location
    USA
    MS-Off Ver
    Office 365, 64 bit
    Posts
    362

    Re: Update cell based on several criteria using VBA

    I will follow this priority order:

    1. MDE
    2. CR #'s (these are unique)
    3. Other (could be more than 1)
    4. Lastly DDE

    At the end, column D will have MDE, CR, Other or DDE populated in all cells up to where there is data in column C....

  13. #13
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: Update cell based on several criteria using VBA

    Ok give this a shot
    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. [SOLVED] Update cell based on several IF criteria
    By rz6657 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-24-2017, 07:41 PM
  2. Status update based on criteria
    By Sanjibghosh in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-20-2017, 04:38 AM
  3. [SOLVED] userform update table based on 3 criteria
    By adamheon in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-29-2016, 04:43 PM
  4. [SOLVED] Update Columns to Another Worksheet, then update another worksheet based on a set criteria
    By mnunnley in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-09-2016, 11:31 AM
  5. Replies: 5
    Last Post: 05-19-2015, 05:49 AM
  6. VBA to update a row based on a criteria.
    By thomasra in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-23-2013, 02:10 PM
  7. Update Masterfile Based on Criteria
    By Sags in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-11-2012, 10:22 AM

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