PC Review


Reply
Thread Tools Rate Thread

calculate various cells to acheive a specific value

 
 
Jennifer_C
Guest
Posts: n/a
 
      27th Jun 2007
Hello,
I am trying to identify two cells within a column that total a specific
amount. For example:

ColA
546
9732
654
6548
687
9871

I need to find the two (or more cells in some cases) that would create the
total of 10,525.

For my current task, I have over 100 rows of data and I know two cells equal
a specific amount, but I do not know which two. Any help, or assistance given
would be greatly appreciated!

Jennifer

 
Reply With Quote
 
 
 
 
Peo Sjoblom
Guest
Posts: n/a
 
      27th Jun 2007
You would need to use code or the solver add-in, for the solver add-in using
your example you would create something like this



546 1
9732 1
654 1
6548 1
687 1
9871 1


assume that is A1:B6 (you would put 1s in B1:B6)

in C1 put

=SUMPRODUCT(A1:A6,B1:B6)


in D1 put

10,525

do tools>solver


then set target cell $C$1 equal to value of 10525
by changing cells $B$1:$B$6

then click add and use $B$1:$B$6 and from dropdown select bin, click OK

then click solve



depending on how large (note that the solver that comes with Excel is
limited)
the range is it can take some time to get a solution, but your example gives
this result

546 0
9732 0
654 1
6548 0
687 0
9871 1


where the 1s in B1:B6 show which 2 amounts total 10,525


I believe Harlan Grove wrote VBA code to do this as well, you can Google on
that


--
Regards,

Peo Sjoblom








"Jennifer_C" <u35395@uwe> wrote in message news:7455401029a02@uwe...
> Hello,
> I am trying to identify two cells within a column that total a specific
> amount. For example:
>
> ColA
> 546
> 9732
> 654
> 6548
> 687
> 9871
>
> I need to find the two (or more cells in some cases) that would create the
> total of 10,525.
>
> For my current task, I have over 100 rows of data and I know two cells
> equal
> a specific amount, but I do not know which two. Any help, or assistance
> given
> would be greatly appreciated!
>
> Jennifer
>



 
Reply With Quote
 
David Biddulph
Guest
Posts: n/a
 
      27th Jun 2007
One way, not necessarily very elegant, is if you've got your data in a
column as your example, copy and paste special in a row across the top of
the sheet to form a square table with your original column values, then add
values from column A and row 1 to form the square.
Conditional format to highlight where the result is 10525, & it shows
9871+654 (or v.v.).
--
David Biddulph

"Jennifer_C" <u35395@uwe> wrote in message news:7455401029a02@uwe...
> Hello,
> I am trying to identify two cells within a column that total a specific
> amount. For example:
>
> ColA
> 546
> 9732
> 654
> 6548
> 687
> 9871
>
> I need to find the two (or more cells in some cases) that would create the
> total of 10,525.
>
> For my current task, I have over 100 rows of data and I know two cells
> equal
> a specific amount, but I do not know which two. Any help, or assistance
> given
> would be greatly appreciated!
>
> Jennifer
>



 
Reply With Quote
 
=?Utf-8?B?Ymo=?=
Guest
Posts: n/a
 
      27th Jun 2007
for two only
in B1 enter
=if(isnumber(match(10525-A1,A:A,0)),10525-A1),"")
copy and paste down
or you could use the match portion in if true to find where it is.

for three, You can set up an NxN table and do something similar
for 4 or more it can get very unwieldy.

I wrote a macro to this one time, and when it didn't solve quickly, I
calculated how long it would take to solve and came up with about a hundred
years of computer time.


"Jennifer_C" wrote:

> Hello,
> I am trying to identify two cells within a column that total a specific
> amount. For example:
>
> ColA
> 546
> 9732
> 654
> 6548
> 687
> 9871
>
> I need to find the two (or more cells in some cases) that would create the
> total of 10,525.
>
> For my current task, I have over 100 rows of data and I know two cells equal
> a specific amount, but I do not know which two. Any help, or assistance given
> would be greatly appreciated!
>
> Jennifer
>
>

 
Reply With Quote
 
Jennifer_C via OfficeKB.com
Guest
Posts: n/a
 
      2nd Jul 2007
Thank you for the input! It was easy to follow, however, it was taking too
long to complete, and I never got a correct answer. I think it might have
been better if I didn't have as much data to work with...
Thank you again!

Peo Sjoblom wrote:
>You would need to use code or the solver add-in, for the solver add-in using
>your example you would create something like this
>
>546 1
>9732 1
>654 1
>6548 1
>687 1
>9871 1
>
>assume that is A1:B6 (you would put 1s in B1:B6)
>
>in C1 put
>
>=SUMPRODUCT(A1:A6,B1:B6)
>
>in D1 put
>
>10,525
>
>do tools>solver
>
>then set target cell $C$1 equal to value of 10525
>by changing cells $B$1:$B$6
>
>then click add and use $B$1:$B$6 and from dropdown select bin, click OK
>
>then click solve
>
>depending on how large (note that the solver that comes with Excel is
>limited)
>the range is it can take some time to get a solution, but your example gives
>this result
>
>546 0
>9732 0
>654 1
>6548 0
>687 0
>9871 1
>
>where the 1s in B1:B6 show which 2 amounts total 10,525
>
>I believe Harlan Grove wrote VBA code to do this as well, you can Google on
>that
>
>> Hello,
>> I am trying to identify two cells within a column that total a specific

>[quoted text clipped - 18 lines]
>>
>> Jennifer


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...tions/200707/1

 
Reply With Quote
 
Jennifer_C via OfficeKB.com
Guest
Posts: n/a
 
      2nd Jul 2007
Thanks for the message. This was the way I was able to get my values. Great
help! However, I'll be stuck if I ever need to find three values!

David Biddulph wrote:
>One way, not necessarily very elegant, is if you've got your data in a
>column as your example, copy and paste special in a row across the top of
>the sheet to form a square table with your original column values, then add
>values from column A and row 1 to form the square.
>Conditional format to highlight where the result is 10525, & it shows
>9871+654 (or v.v.).
>> Hello,
>> I am trying to identify two cells within a column that total a specific

>[quoted text clipped - 18 lines]
>>
>> Jennifer


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...tions/200707/1

 
Reply With Quote
 
Jennifer_C via OfficeKB.com
Guest
Posts: n/a
 
      2nd Jul 2007
Thanks for the feedback for multiple values! I will need this for looking at
multiples! Very handy!

bj wrote:
>for two only
>in B1 enter
>=if(isnumber(match(10525-A1,A:A,0)),10525-A1),"")
>copy and paste down
>or you could use the match portion in if true to find where it is.
>
>for three, You can set up an NxN table and do something similar
>for 4 or more it can get very unwieldy.
>
>I wrote a macro to this one time, and when it didn't solve quickly, I
>calculated how long it would take to solve and came up with about a hundred
>years of computer time.
>
>> Hello,
>> I am trying to identify two cells within a column that total a specific

>[quoted text clipped - 16 lines]
>>
>> Jennifer


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...tions/200707/1

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import data to specific cells for a specific row Netta Microsoft Excel Misc 0 27th Jan 2009 04:23 PM
How cpould we acheive the hosts list for TCP/IP? =?Utf-8?B?RHIuSGVzaGFtIEVsQmFkYXd5?= Windows Vista General Discussion 3 24th Aug 2007 01:37 AM
How to acheive this ? Sriram Windows XP Internet Explorer 0 4th May 2006 01:48 PM
Form a circle (ie. color specific cells) given specific radius =?Utf-8?B?RGF2aWQ=?= Microsoft Excel Programming 5 11th Apr 2006 03:56 PM
I need to acheive true automation =?Utf-8?B?SmltIFJlbmRhbnQ=?= Microsoft Access VBA Modules 0 20th Aug 2004 01:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:42 PM.