I have an Excel 2010 workbook that contains a number of individual worksheets. The cells on one of the sheets are linked to individual cells on two other worksheets in the same workbook. I'm using a direct cell reference that essentially says that whatever value is entered into a particular cell on one sheet also populates cells on two other sheets. I used the (=) function with the cell reference to accomplish this.
The issue I'm running into is that, even when the primary cell is left blank, the cells that populate from that primary cell will display 0, rather than remaining blank themselves.
I want the subordinate cells to remain blank if the primary cell they're linked to is blank.
217 Answers
You need to force Excel to treat the contents of the cell as a text value instead of a number, which it does automatically with blank values.
=A2 & ""This will force Excel into making that cell reference a text value, thus preventing the conversion of blanks into zeroes.
3Here are three answers:
1) Letting other.cell.reference represent the reference formula that you currently have after the = (e.g., Sheet17!$H$42), replace that link reference with
=IF(other.cell.reference<>"",other.cell.reference, "")
2) Set the “Number” format of your linked cells to “Custom”: General;–General;.
3) In “Excel Options”, “Advanced” page, “Display options for this worksheet” section, clear the “Show a zero in cells that have a zero value” checkbox. Warning: this will cause all zeroes in the worksheet to disappear.
6IF your reference data is only either a numeric type (non-text) or empty, and you may have 0's, then this is my preferred approach, with only entering formula once. Admittedly, a slightly indirect way, but it is best I think because:
- you don't need extra cells to put the formula in and then reference the second cells
- you don't need to type the formula twice
- this method differentiates between a zero value and an empty cell
- doesn't require VBA
- doesn't require Named Ranges
Downfall: If you need text data returned this this will not work. For text data my preferred method is using number format as mentioned in other answers above.
=IFERROR((A1 & "") * 1,"")A1 in this instance can be replaced by any cell, including another sheet, workbook, or INDIRECT().
Notes on how this works:
IFERROR() - second argument is set to empty string, so if an error occurs we get an empty string. So we need to make sure if the source cell is empty, an error is triggered.
Numeric method: Stringify the source value, then multiply by 1. Literal emtpy string * 1 = #VALUE, String with numeric is auto-converted to numeric and no error occurs.
2There is another trick: set the soucre empty cell to formula ="". See the detailed description here.
I too did not find a better solution than the Scott's one.
But combined with the approach from here it could be almoste bearable, I think:
Let's say I have formula like this
= IFERROR( INDEX(INDIRECT("EsZkouska"); SMALL(IF((INDEX(INDIRECT("EsZkouska");;1;1)="ČSN721180")*(INDEX(INDIRECT("EsZkouska");;9;1)="RC_P_B"); ROW(INDIRECT"EsZkouska"))-MIN(ROW(INDIRECT("EsZkouska")))+1;"");1);17;1);"")This formula reads cell value from a data sheet using conditional select and presents them on another sheet. I have no control over cell formating on the data sheet.
I go to Insert > Name > Define and in the "Names in workbook" I create new Name "RC_P_B". Then into the "Refers to" field I copy my formula (without {} characters - it is array formula).
Then you can use Scott's formula whithout having to repeat the whole formula text:
{=IF(RC_P_B<>""; RC_P_B;"---")}I believe this is better than to copy the whole formula.
I simple don't use a formula to overcome this problem. All I do is to conditionally format cells to font color white if cell value equals 0.
2If the linked cell is non-numeric you can use an IF statement with ISTEXT:
=IF(ISTEXT(Sheet1!A2), Sheet1!A2, "") 2 I have long searched for an elegant solution to this issue.
I have used formula =if(a2="","",a2) for years, but I find it to be a bit cumbersome.
I tried above suggestion =a2&"" and although it does appear to work it shows a number that is actually text so number formatting cannot be applied and no statistical operations work, such as sum, average, median, etc., so if it's workable numbers you're looking for this doesn't fit the bill.
I experimented with some of the other functions and found what I think is the most elegant solution to date. Continuing the above example:
=CELL("contents",A2)
returns a numerical value that can be formatted as a number and it returns a blank when the referenced cell is blank. For some reason, this solution doesn't seem to appear in any of the online suggestions I've found, but it
1Solution for Excel 2010:
- Open "File"
- Press "Options"
- Click "Advanced"
- Under "Display Options" for this worksheet "BBBB"
- Untick the box "Show a zero value for cells that have a zero value."
Public Function FuncDisplayStringNoValue(MyCell As Variant) As String
Dim Result As Variant
If IsEmpty(MyCell) Then FuncDisplayStringNoValue = "No Value"
Else Result = CDec(MyCell) Result = Round(Result, 2) FuncDisplayStringNoValue = "" & Result End If
End Function I have a solution working for me:
IF(cell reference="","",cell reference)Explanation:
"" is equal to blank or empty cell.
Now I only turn the if around. If cell is blank, make it blank, otherwise use the cell reference.
I used conditional formatting to format the font to be the same color as the cell background where the cell value was equal to zero.
2I had a similar problem, and I think I found a method for you. It fixed my issues.
If you want column C to reference column A, and only write a formula for the reference cell, you would use this and drag down the column.
=A1However, there may be source cells in column A that are blank and need to remain blank in the reference cells in column C, you can use this and drag the down column.
=T(A1)As far as cell formatting goes, the reference (columnn C) will need to be general.
5What worked for me in Office 2013 was:
=IF(A2=""," ",A2)Where on the first set of quotations there is no space, and on the second set there is a space.
Hope this helps
1Go to Format Cells.
Then select custom format,
and enter the following:0;-0;;@
Solution:=IF('Wk1 Data-replace w dt bgn & end'!C2>0, 'Wk1 Data-replace w dt bgn & end'!C2, "")
Explanation:
To solve this problem I used two sets of If commands.
Part one of command:
I told the cell to display the contents of the reference cell if the reference cell contained data (Excel interprets this as the cell having a value larger than 0)
Part two of command:
I told it how to behave if there was no data; "" means leave blank
Note: Wk1 Data-replace w dt bgn & end'!C2 is my reference cell.
1All these solutions are way too complicated for me and I realize this may not be a feasible for all applications but I just fill the source field with a blank and i get a blank in the destination field.
2