LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 12
Default Can excel find a sequence of numbers from a known total?

Hello Chip,

That sir, is fantastic!. it did for me in the blink of an eye, what I have
previously spent an eye-straining excessive amount of time on...

thank you

much appreciated.


regards

Eric

"Chip Pearson" wrote:

If I understand your question properly, you want find a contiguous range of
cells that adds up to a particular number, 68 in your example. The following
code will search column A looking for a series of contiguous cells that add
up to the value in cell B1. It will scan until either the answer is found or
a blank cell is encountered in column A, in which there is no series that
adds up to Answer.

Sub FindSeries()

Dim StartRng As Range
Dim EndRng As Range
Dim Answer As Long
Dim TestTotal As Long

Answer = Range("B1") '<<< CHANGE

Set StartRng = Range("A1")
Set EndRng = StartRng
Do Until False
TestTotal = Application.Sum(Range(StartRng, EndRng))
If TestTotal = Answer Then
Range(StartRng, EndRng).Select
Exit Do
ElseIf TestTotal Answer Then
Set StartRng = StartRng(2, 1)
Set EndRng = StartRng
Else
Set EndRng = EndRng(2, 1)
If EndRng.Value = vbNullString Then
MsgBox "No series found"
Exit Do
End If
End If
Loop
End Sub



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"efandango" wrote in message
...
Can excel find (and highlight) a continuous sequence of numbers using a
known
total as reference from the following list of numbers?

the answer is 68.

8
6
3
2
6
10
9
4
12
8
6
1
8
10
8
14
10
9
12
12
14
6
4
3
4
4
4
0
6
10
4
9
6
3
11
12
10
7
12
8
8






 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can excel find a sequence of numbers from a known total? efandango Excel Discussion (Misc queries) 16 February 15th 07 11:40 PM
find numbers in a list which sum a total LINDA Excel Worksheet Functions 1 September 22nd 06 02:06 PM
find missing numbers in a sequence kaytoo Excel Discussion (Misc queries) 1 June 13th 06 05:09 PM
find missing numbers in a sequence kaytoo Excel Discussion (Misc queries) 1 June 13th 06 04:43 PM
How do I find a missing number in a sequence of numbers? Nash Excel Worksheet Functions 2 August 11th 05 04:22 AM


All times are GMT +1. The time now is 08:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"