Solved

Excel Changing cell value based on another cell, but not always

Posted on 2013-11-15
4
4,976 Views
Last Modified: 2014-05-15
Is there any way to have a cell change its value based on another cell, but also be able to enter a cell value if the first cell had nothing in it without wiping out a formula?

Ex:

If Cell A1 has a value of 1
I want Cell B1 to have a value of 1 automatically.

But if Cell A1 has no value,
I want Cell B1 to be able to have a value put in without overwriting the formula.

Is that at all possible? Perhaps by having a formula in another cell, say C1, that is monitoring the value of A1, and if it has a value, place that value in B1?

Thanks.
0
Comment
Question by:repco
4 Comments
 
LVL 35

Accepted Solution

by:
[ fanpages ] earned 167 total points
ID: 39652422
Hi,

A single cell can have either an explicit value (such as a number, text, or a date), or a value derived from the presence of a formula.

It cannot have both a value & a formula (unless the value is the result of the formula).

That is, it cannot have both one value & a formula that results in another value.

However, Visual Basic for Applications [VBA] code can be introduced into your workbook so that whenever another cell's value changes, the value of cell [B1] can change to suit your needs.

This could be either an explicit value, or a value derived from a formula (but not both at once).

The VBA code within the Worksheet_Change() event would determine what [B1] contained.

Please advise if you would wish to see a demonstrate of this.  If possible, could you attach (upload) your existing workbook so that the necessary code can be added to this directly (& then re-attached for you to download)?

BFN,

fp.
0
 
LVL 14

Assisted Solution

by:sentner
sentner earned 166 total points
ID: 39652466
Easiest way would probably be to have another cell contain the data for the default.

For example, setting B1 to:

=if(A1=1,1,C1)

This would put a 1 if A1=1, otherwise it'd use the value of C1.
0
 

Author Comment

by:repco
ID: 39652520
Thanks for the input. In the end, I'll just have to change the way the form works as I cannot use VBA, nor does it have a default value. VBA will work though, so I'll give you points for that.
0
 
LVL 14

Assisted Solution

by:frankhelk
frankhelk earned 167 total points
ID: 39656144
A simple way for that would be the use of an intermediate cell for that.

Imagine A1 is your "input" cell, which could contain an value or be empty.
Cell A2 (which supplies the value to subsequent formulas) could contain a formula like this:

=IF(A1="";(formula);A1)

or

=IF(ISEMPTY(A1);(formula);A1)

That way the value of A1 is supplied to the subsequent formula if it is present, and the formula result if A1 is empty.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
This article will show you how to use shortcut menus in the Access run-time environment.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question