Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-11-15
4
Medium Priority
?
6,089 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 668 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 664 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 668 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

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Question has a verified solution.

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

Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

876 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