Solved

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

Posted on 2013-11-15
4
4,803 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

This article will show you how to use shortcut menus in the Access run-time environment.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

773 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