Excel formula

  • Thread starter Thread starter azarat
  • Start date Start date
A

azarat

I regularly use the formula =sum()-sum(). My question is how or can I create
a formula shortcut and to just fill in between the brackets to complete my
equation. I would like the shortcut to be readily available instead of always
having to retype it in. Can a shortcut be placed on a toolbar or within the
autofil shortcut on toolbar.
Thank you.
 
Once you type the =SUM( you are in edit mode so you cannot invoke the
shortcut at that point. You would have to writ e a macro to return the whole
formula.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Two alternatives
1) a UDF
Function diff(r1, r2)
For j = 1 To r1.Count
diff = diff + r1(j)
Next j
For j = 1 To r2.Count
diff = diff - r2(j)
Next j
End Function

call with =DIFF(B1:B5,A1:A5)
the two ranges need not be the same size

2) =SUMPRODUCT(r1-r2) as in =SUMPRODUCT(A1:A5-B1:B5)
the two ranges must be the same size
 
I wonder if there is any break-even point for the number of cells covered by
the ranges after which this UDF might become more efficient than the one you
proposed?

Function DIFF(R1 As Range, R2 As Range) As Double
DIFF = Application.WorksheetFunction.Sum(R1) - _
Application.WorksheetFunction.Sum(R2)
End Function

Rick
 
I regularly use the formula =sum()-sum(). My question is how or can I create
a formula shortcut and to just fill in between the brackets to complete my
equation. I would like the shortcut to be readily available instead of always
having to retype it in. Can a shortcut be placed on a toolbar or within the
autofil shortcut on toolbar.
Thank you.

Maybe you need a template file already set up with your formulas
instead of VBA code to constantly re-create them.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top