Variables in Excel

P

Prospero

I am trying to find something equivalent to the variables that I a
familiar with from programming in QBASIC.

For example:

A1 contains 50
A2 contains 30

Am I able to write a formula something like variable=a1+a2, so that
can call up a running total when I need to?

Obviously, I know about SUM but this is not suitable for th
spreadsheet I am trying to make
 
D

Dave Peterson

You could use a defined name:

Insert|name|define
Names in workbook: MySum (or what you want)
refers to: =SUM(Sheet1!$A$1:$A$2)

Then you could use =mysum in a cell or even =33+mysum.
 
J

Jim May

The Macro Recorder performed this (producing a VBA code solution):

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 9/19/2004 by James May
'
Range("C1").FormulaR1C1 = "=SUM(RC[-2]:R[1]C[-2])"
End Sub
 
Top