Can I put an expression in a cell?

T

Top Spin

I am doing a comparison of disk capacities. I would like to make a
table showing various configurations and how much data can be stored
on each. Each configuration will have 1 or more disks.

I would like to put an expression for the total capacity in the first
cell, the result of that in the second cell, and then do calculations
on that for the rest.

I tried this:

A B
2*160 =A1

That just puts "2*160" in A2, which appears to be text, because the
derivative calculations all get errors.

Is there a way to do this?

Thanks

PS: I don't want to have a cell for numer of disks and a second for
capacity because they may not all be the same. I may need to put
something like 300+300+160.

--
PC: HP Omnibook 6000
OS: Win 2K SP-4 (5.00.2195)
LAN: P2P with an HP Vectra workstation
Email: Usenet-20031220 at spamex.com
(11/03/04)
 
J

JulieD

Hi

just put a = in front to indicate to excel that it's a formula
e.g.
=2*160
=10+20+30

Cheers
JulieD
 
T

Top Spin

Hi

just put a = in front to indicate to excel that it's a formula
e.g.
=2*160
=10+20+30

I should have said that I tried that. It works, but it shows the
result in the cell -- not the formula. I would like it to show "2*160"
in the cell and the result (320) in the next cell.

Thanks
Cheers
JulieD


--
PC: HP Omnibook 6000
OS: Win 2K SP-4 (5.00.2195)
LAN: P2P with an HP Vectra workstation
Email: Usenet-20031220 at spamex.com
(11/03/04)
 
B

Bernard Liengme

To get the first (text), just type 2*60
To get the result type =2*60. If this does not display 120 there are a few
things to try:
a) do you have 'display formulas' switched on? To toggle on/off use CTRL+`
(the accent on the same key as tilde; next to the 1 on US/UK keyboards
b) is the cell formatted as text? Select the cell, use Format Cells and give
it General format; press F2 and hit Enter

best wishes
 
T

Top Spin

To get the first (text), just type 2*60
To get the result type =2*60. If this does not display 120 there are a few
things to try:
a) do you have 'display formulas' switched on? To toggle on/off use CTRL+`
(the accent on the same key as tilde; next to the 1 on US/UK keyboards
b) is the cell formatted as text? Select the cell, use Format Cells and give
it General format; press F2 and hit Enter

I would prefer not to have to enter the expression twice. I want to
enter the expression in the first cell (An) and have it display as
text. I want the result of that expression to be displayed in the
second cell (Bn) and have it calculated from the expression in the
first cell. I don't care if the data in the first cell is text or
numeric or what, but the second cell needs to be numeric so I can use
it for calculations.

A B C
Disks Capacity Hours
2*160 320 45
300+150 450 55

Thanks for the tip on C+`. I didn't know that one. The problem is, it
affects the entire spreadsheet-- not just that cell.




--
PC: HP Omnibook 6000
OS: Win 2K SP-4 (5.00.2195)
LAN: P2P with an HP Vectra workstation
Email: Usenet-20031220 at spamex.com
(11/03/04)
 
G

Gord Dibben

Top Spin

Could you use a User Defined Function?

Function EvalCell(RefCell As String)
Application.Volatile
EvalCell = Evaluate(RefCell)
End Function

Enter 2*60(as text) in A1

Enter =EvalCell(A1) in B1 to get 120

If not familiar with VBA and macros, see David McRitchie's site for more on
"getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In the meantime..........

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + R to open Project Explorer.

Find your workbook/project and select it.

Right-click and Insert>Module. Paste the above code in there. Save the
workbook and hit ALT + Q to return to your workbook.


Gord Dibben Excel MVP
 
T

Top Spin

Top Spin

Could you use a User Defined Function?

Yes, I suppose so. I was hoping there would be something built in. It
would be nive to have an Evaluate() function.

Thanks
Function EvalCell(RefCell As String)
Application.Volatile
EvalCell = Evaluate(RefCell)
End Function

Enter 2*60(as text) in A1

Enter =EvalCell(A1) in B1 to get 120

If not familiar with VBA and macros, see David McRitchie's site for more on
"getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In the meantime..........

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + R to open Project Explorer.

Find your workbook/project and select it.

Right-click and Insert>Module. Paste the above code in there. Save the
workbook and hit ALT + Q to return to your workbook.


Gord Dibben Excel MVP


--
PC: HP Omnibook 6000
OS: Win 2K SP-4 (5.00.2195)
LAN: P2P with an HP Vectra workstation
Email: Usenet-20031220 at spamex.com
(11/03/04)
 

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

Top