Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-11-15
4
Medium Priority
?
5,835 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

730 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