Evaluating a cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

if the content of a cell is the string made up of ="=sum(d3."&"d"&"1000)" which shows up as =sum(d3.d1000) how would one actually evaluate this in another cell so it would show the sum of the column d from cell 3 to 1000. Is there no eval(c1) or equivalent...
 
Phillip,

Not sure what you're asking in terms of the string, but here's some
code to sum a column.

dc

Sub sum_column()

'select the range of cells you want to sum
Range("D3:D1000").Select
'activate the cell where you want to show the answer
Range("D1001").Activate
'write the answer using references rows in relation to the output cell
ActiveCell.FormulaR1C1 = "=SUM(R[-998]C:R[-1]C)"

End Sub
 
Try this UDF

Function EvalCell(RefCell As String)
EvalCell = Evaluate(RefCell)
End Function

Usage is: =EvalCell(cellref)

Where cellref contains =SUM(D3:D1000) or simply SUM(D3:D1000) or A1 + A2

Gord Dibben XL2002
 
Back
Top