Variables in Excel

  • Thread starter Thread starter Prospero
  • Start date Start date
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
 
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.
 
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
 

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