Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have developed an Excel VBA based application. I want one feature i the application such that to the existing formula value of one mor cell gets added on a button click. For example, I have a formula for Cell 1 as "=C2+C3+C4". I have a button placed below it which when presses once converts thi formula to "=C2+C3+C4+C5". Please tell me if this is possible to be done programatically. Thanks, Samee -- Message posted from http://www.ExcelForum.com |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
try something like with activesheet.range("A1") ..formula=.formula & "+C5" end with -----Original Message----- Hi, I have developed an Excel VBA based application. I want one feature in the application such that to the existing formula value of one more cell gets added on a button click. For example, I have a formula for Cell 1 as "=C2+C3+C4". I have a button placed below it which when presses once converts this formula to "=C2+C3+C4+C5". Please tell me if this is possible to be done programatically. Thanks, Sameer --- Message posted from http://www.ExcelForum.com/ . |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
No Frank, the formula you suggested is not working.
Any other suggestions -- Message posted from http://www.ExcelForum.com |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
I added one dot too much. try: with activesheet.range("A1") ..formula=.formula & "+C5" end with If this does not work please describe exactly what is not working! -----Original Message----- No Frank, the formula you suggested is not working. Any other suggestions? --- Message posted from http://www.ExcelForum.com/ . |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On the off hand chance you might want to press the button more than once,
this might be a possibility: Sub AddNextRow() Dim rng As Range, rng1 As Range Dim rng2 As Range Set rng = Range("B9") On Error GoTo ErrHandler Set rng1 = rng.DirectPrecedents Set rng2 = rng1.Areas(rng1.Areas.Count) Set rng2 = rng2(rng2.Count)(2) rng.Formula = rng.Formula & "+" & rng2.Address(0, 0) ErrHandler: End Sub -- Regards, Tom Ogilvy "sameerce " wrote in message ... No Frank, the formula you suggested is not working. Any other suggestions? --- Message posted from http://www.ExcelForum.com/ |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Do you really need such a button, can't you just use the
SUM Worksheet Function with a range. Aren't there better solutions: Use of OFFSET allows you to insert and delete rows right up to inserting a line before the SUM formula. A30: =SUM(A2:OFFSET(A30,-1,0)) would sum numbers from A2:A29 You can use the SUM button, which would, I think, be preferable to your request but it does have a problem if you insert after or delete the last reference in the range. By adding in cells one by one you have the advantage or disadvantage of getting a #Value! if a cell contains text. But you should be aware that there is a specification limit as to the size of a formula. Arguments in a function 30 Length of formula contents 1,024 characters The second one could be a problem for you, as you could only reach up to 228 cells to be added from a column, if you include all of the individual addresses. i.e. A229: =SUM(A2:OFFSET(A227,-1,0)) as opposed to your A229: =A1+A2+A3+A4+A5+A6+A7+A8+A9+A10+A11+A12+ ... + A228) Hope you are not using this for a running total, which could take outlandish calculation times by adding up the same numbers over an over as opposed to the previous running total + increment. --- HTH, David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001] My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm Search Page: http://www.mvps.org/dmcritchie/excel/search.htm "sameerce " wrote in message ... Thanks a ton to all. It worked. --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Install Program starts when selecting formula | Excel Worksheet Functions | |||
how do i put a formula in a macro to run a program | Excel Worksheet Functions | |||
My excel program will not let me edit in the formula bar. | Excel Discussion (Misc queries) | |||
Formula not updating | Excel Worksheet Functions | |||
merging excel program with tdc finance program | Excel Programming |