+ Reply to Thread
Results 1 to 14 of 14

Multiple Criteria match with highlighted data required by VBA code

  1. #1
    Forum Contributor
    Join Date
    12-01-2020
    Location
    Asia
    MS-Off Ver
    MS Office 2024 Preview
    Posts
    277

    Multiple Criteria match with highlighted data required by VBA code

    Hi,

    Looking for VBA code that could automatically generate the data as highlighted with yellow. i.e from I5 to S17 could be increased at right and below as data gets increased.

    Plz find in attachment file.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    09-03-2016
    Location
    Catania, Italy
    MS-Off Ver
    Excel 2019
    Posts
    188

    Re: Multiple Criteria match with highlighted data required by VBA code

    HI
    Why VBA? Wouldn't Conditional Formatting for the desired range suffice if the cell is not empty?
    Look at your attachment with the FC.

    HI,
    Mario
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    12-01-2020
    Location
    Asia
    MS-Off Ver
    MS Office 2024 Preview
    Posts
    277

    Re: Multiple Criteria match with highlighted data required by VBA code

    You didn't understand what I mean to say.Refer see my attachment now.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    09-03-2016
    Location
    Catania, Italy
    MS-Off Ver
    Excel 2019
    Posts
    188

    Re: Multiple Criteria match with highlighted data required by VBA code

    Hi

    Sorry, i don't understand

    Hi,
    Mario

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,835

    Re: Multiple Criteria match with highlighted data required by VBA code

    Deleted.............
    Last edited by jindon; 05-22-2023 at 12:38 AM.

  6. #6
    Forum Contributor
    Join Date
    12-01-2020
    Location
    Asia
    MS-Off Ver
    MS Office 2024 Preview
    Posts
    277

    Re: Multiple Criteria match with highlighted data required by VBA code

    There was missing data in O3 which will be 2 has now been updated in below attached file.

    I hope vba experts will help.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    12-01-2020
    Location
    Asia
    MS-Off Ver
    MS Office 2024 Preview
    Posts
    277

    Re: Multiple Criteria match with highlighted data required by VBA code

    After a long search.I am able to get below code.It gives correct result prompting with an error only in a condition when A:D are in value format and not in formula format.

    Can vba experts,help in changing below code so that it can works in formula format in A:D.

    Please Login or Register  to view this content.
    Last edited by Etax; 05-24-2023 at 02:59 AM.

  8. #8
    Forum Contributor
    Join Date
    12-01-2020
    Location
    Asia
    MS-Off Ver
    MS Office 2024 Preview
    Posts
    277

    Re: Multiple Criteria match with highlighted data required by VBA code

    Hi, Experts,Is there possibilities that above code can be converted to work in formula based format or not.

  9. #9
    Registered User
    Join Date
    12-30-2021
    Location
    Toronto
    MS-Off Ver
    365
    Posts
    51

    Re: Multiple Criteria match with highlighted data required by VBA code

    It seems that I understand what you want. Take Column I as an example. The quantity is 50 and you have 10, 15, and 17 satisfying
    criteria 1 and 2. However, the sum of these 3 numbers is still short of 8. Hence, you want write 8, 10, 15, and 17 in Column I.
    Am I right?
    Your column S is still not correct. Or maybe I am wrong. If the quantity is less than whatever available, just fill that number.

    Are A3:D4 always empty?
    Last edited by Torontohrb; 05-24-2023 at 05:15 PM.

  10. #10
    Registered User
    Join Date
    12-30-2021
    Location
    Toronto
    MS-Off Ver
    365
    Posts
    51

    Re: Multiple Criteria match with highlighted data required by VBA code

    My understanding is you want to write numbers in those highlighted cells. If your raw data always start from cell A5, the following code should work.

    I have no incentive to write VBA code any more. I wrote it using Office Scripts, which I think it is easier than VBA and it will replace VBA soon. It is not too complicated, but tedious.

    If you use Office 365, click Automate tab, then click 'New Script' and copy the following code and run. Please let me know if it works on your computer.

    In case you want to add a column in Column T, simply change 6 in the code to 7 (two places).

    Please Login or Register  to view this content.
    Last edited by Torontohrb; 05-24-2023 at 08:20 PM.

  11. #11
    Forum Contributor
    Join Date
    12-01-2020
    Location
    Asia
    MS-Off Ver
    MS Office 2024 Preview
    Posts
    277

    Re: Multiple Criteria match with highlighted data required by VBA code

    No,I am using office. 2021.No,Office scripts doesn't seems to work in my version of excel.
    Last edited by Etax; 05-24-2023 at 08:57 PM.

  12. #12
    Forum Contributor
    Join Date
    12-01-2020
    Location
    Asia
    MS-Off Ver
    MS Office 2024 Preview
    Posts
    277

    Re: Multiple Criteria match with highlighted data required by VBA code

    Quote Originally Posted by Torontohrb View Post
    It seems that I understand what you want. Take Column I as an example. The quantity is 50 and you have 10, 15, and 17 satisfying
    criteria 1 and 2. However, the sum of these 3 numbers is still short of 8. Hence, you want write 8, 10, 15, and 17 in Column I.
    Am I right?
    Your column S is still not correct. Or maybe I am wrong. If the quantity is less than whatever available, just fill that number.

    Are A3:D4 always empty?

    Here ,8=50-(10+15+17) i.e [I4-Sum(I6:I8)]
    Column S is correct,becoz both criteria matches,hence from D11 which is 20,it takes 10 only as S4 in S11.But if S4 was 25 after satisfying both criteria,the value would be S11=20 and S10=5(taking 5 only from D10 which is holding value 75.whose calculation is same as S10=S4-Sum(S11:S11) i.e 25=25-(10).

    A3:D4 are coming due to formula.This part also I would like to trim and remove as well.Plz refer in my above file there is formula in A3.Necessary changes can be done at your end by changing the formula to achieve the result.However ,it looks from A5 excluding heading.

    I hope,I have given reply to all the queries.
    Last edited by Etax; 05-24-2023 at 09:23 PM.

  13. #13
    Forum Contributor
    Join Date
    12-01-2020
    Location
    Asia
    MS-Off Ver
    MS Office 2024 Preview
    Posts
    277

    Re: Multiple Criteria match with highlighted data required by VBA code

    To all the experts> Interpretation,

    The sum of each column from row 5 to 17 should equal the value in row 4. Only use values from column D. Start with the last row where the product and month in column A & B match the product and month in row 2 & 3. Then continue using the values from previous rows until the total would exceed row 4.

    If the next value in column D would cause the total to exceed row 4, just enter the value needed to equal row 4.

    Example Column I:

    Target value is 50

    Last matching row is row 8.

    Row 8 value is 17, total is 17, enter 17 in I8

    Row 7 value is 15, total is (17 + 15 = 32), enter 15 in I7

    Row 6 value is 10, total is (17 + 15 + 10 = 42), enter 10 in I6

    Row 5 value is 10, total would be (17 + 15 + 10 + 10 = 52) which exceeds the target. The value needed to meet the target is (50 - 42 = 8). Enter 8 in I5.

  14. #14
    Forum Contributor
    Join Date
    12-01-2020
    Location
    Asia
    MS-Off Ver
    MS Office 2024 Preview
    Posts
    277

    Re: Multiple Criteria match with highlighted data required by VBA code

    # Post 7: formula interpretation:

    Source:from Internet.

    Please Login or Register  to view this content.
    I think this will help the experts to resolve this issue.
    Last edited by Etax; 05-25-2023 at 03:49 AM.

+ 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] Index Match solution required for multiple criteria with merged cell
    By pavanbhoyar in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-20-2022, 12:12 PM
  2. Optimize VBA code: Match multiple criteria
    By pezalmendra in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-26-2017, 08:56 AM
  3. [SOLVED] Is an array required for index-match with multiple criteria?
    By trolle in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-03-2017, 05:29 AM
  4. VBA Code for Index Match (multiple criteria) on Customer Data Sheet - Data Enrichment
    By JPaint005 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-20-2017, 10:05 AM
  5. [SOLVED] Formula Required to Lookup and Match Multiple Criteria
    By The_Snook in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-06-2014, 10:59 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