Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3970388
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:04:48+00:00 2026-05-20T04:04:48+00:00

Here’s sample sheet: ColA, ColB, ColC A, 0.2, 10% A, 0.3, 1% A, 0.5,

  • 0

Here’s sample sheet:

ColA, ColB, ColC
A, 0.2, 10%
A, 0.3, 1%
A, 0.5, 6%
B, 0.4, 9%
B, 0.3, 8%
B, 1.2, 40%

I have to find minimum value in ColB for specified value in ColA, then check if ColC in this row is greater than 15%. If so – return value of ColB. If not, find next minimum value and sum with previously found value, then again check if sum is greater than 15%, and so on.. Return last summed value from ColB.

Example (for ColA=”A“):
1. find minimum value in ColB (cell: B2, value 0.2)
2. check if value in ColC in this row (cell: C2, value 10%) is greater than 15% (not met!) sum with previously val = 0 + 10% = 10%
3. take next minimum value in ColB (cell: B3, value 0.3)
4. check >15% condition -> (cell: C3, value 1%) sum with previously val = 10% + 1% = 11% (still not met)
5. take next minimum value in ColB (cell: B4, value 0.5)
6. check >15% condition -> (cell: C4, value 6%) sum with previously val = 11% + 6% = 17% (condition met)
7. The last cell we summed was C4, so we return value from ColB in this row – 0.5

(Answer for “B” is 0.4)

I’d like to ask for any hints to solve this problem. Hope it’s clear 😉

Here’s the prototype of my function
Function foo(ColA As String) As Integer

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T04:04:49+00:00Added an answer on May 20, 2026 at 4:04 am
    Function Foo(rng As Range, ColA As String, Target As Variant) As Variant
        Dim Dat() As Variant
        Dim r As Long, c As Long
        Dim sm As Variant
    
        ' Get Data from sheet
        Dat = rng.Value2
        ' Sort DAT on column B
        ' <sort code here>
    
        sm = 0#
    
        ' Loop through rows
        For r = LBound(Dat, 1) To UBound(Dat, 1)
            ' If Column 1 matches
            If Dat(r, 1) = ColA Then
                ' sum of column 3
                sm = sm + Dat(r, 3)
    
                ' If target reached
                If sm >= Target Then
                    ' Return result
                    Foo = Dat(r, 2)
                    Exit Function
                End If
            End If
        Next
    
        ' Target not reached
        Foo = "No Answer"
    
    End Function
    

    Call function like this (replace $A$1:$C$6 to suit your sheet)

    =Foo($A$1:$C$6,"A",15%)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is what I am trying to achieve in PHP: I have this string:
Here's a problem I ran into recently. I have attributes strings of the form
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Here's a coding problem for those that like this kind of thing. Let's see
Here we go again, the old argument still arises... Would we better have a
Here's an excerpt from java.text.CharacterIterator documentation: This interface defines a protocol for bidirectional iteration
Here, i have coded to get data from DB. I want to store the
here's what I currently have, unfortunately I cannot seem to figure out how to
Here's the issue... if I use, say a directory catalog in MEF and have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.