Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 577
Default Sum of Numbers Smaller than input

If I want to be able to input a number in a cell and in another cell take the
sum of the number with all of the numbers smaller than it without a macro how
would I do it?

Example:
If I put a 6 in a cell, I want another cell to output 21 (6+5+4+3+2+1)

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Sum of Numbers Smaller than input


You need to create a custom Function


Code:
--------------------
Function SUMInt(i As Long)
Dim c As Long
Dim r As Long

r = i

For c = 1 To i
r = r + (i - c)
Next c

SUMInt = r


End Function
--------------------


--
Excelenator


------------------------------------------------------------------------
Excelenator's Profile: http://www.excelforum.com/member.php...o&userid=36768
View this thread: http://www.excelforum.com/showthread...hreadid=567606

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Sum of Numbers Smaller than input


Dave that's FREAKIN AWESOME!!!!


--
Excelenator


------------------------------------------------------------------------
Excelenator's Profile: http://www.excelforum.com/member.php...o&userid=36768
View this thread: http://www.excelforum.com/showthread...hreadid=567605

  #4   Report Post  
Posted to microsoft.public.excel.misc
bj bj is offline
external usenet poster
 
Posts: 1,397
Default Sum of Numbers Smaller than input

try
=IF(MOD(A1,2)=0,(A1+1)*(A1/2),(A1*((A1-1)/2)+A1))
if you want 6 = 21 and 6 is in A1

From what you asked (Sum of numbers less than the input number)
=if(MOD(A1,2)=1,A1*(A1-1)/2,(A1-1)*(A1-2)/2+A1-1)
if you really wanted 6=15

"Scott" wrote:

If I want to be able to input a number in a cell and in another cell take the
sum of the number with all of the numbers smaller than it without a macro how
would I do it?

Example:
If I put a 6 in a cell, I want another cell to output 21 (6+5+4+3+2+1)

Thanks!

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,339
Default Sum of Numbers Smaller than input

=A1*(A1+1)/2

Sum of digits 1 to n =n(n+1)/2

HTH

"bj" wrote:

try
=IF(MOD(A1,2)=0,(A1+1)*(A1/2),(A1*((A1-1)/2)+A1))
if you want 6 = 21 and 6 is in A1

From what you asked (Sum of numbers less than the input number)
=if(MOD(A1,2)=1,A1*(A1-1)/2,(A1-1)*(A1-2)/2+A1-1)
if you really wanted 6=15

"Scott" wrote:

If I want to be able to input a number in a cell and in another cell take the
sum of the number with all of the numbers smaller than it without a macro how
would I do it?

Example:
If I put a 6 in a cell, I want another cell to output 21 (6+5+4+3+2+1)

Thanks!

Reply
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
Sum of Numbers Smaller than input David Billigmeier Excel Discussion (Misc queries) 0 August 2nd 06 08:43 PM
Help! How do you get excel to find the x(changes daily, marked in a cell from another formula) highest numbers in a group of numbers and sum them up? C-Man23 Excel Worksheet Functions 1 January 9th 06 01:23 PM
random number with text T Harris Excel Worksheet Functions 10 December 30th 05 04:34 PM
Why don't fields update automatically when new numbers are input?. Frustrated in NJ Excel Discussion (Misc queries) 2 February 25th 05 03:07 PM
can you input time (hh:mm:ss) without having to input the colon i. Lexicon Excel Discussion (Misc queries) 4 January 11th 05 02:09 PM


All times are GMT +1. The time now is 04:00 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"