Formula Populating Cell With A Zero When It Should Be Empty

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Code:
.Range("C6:C17").Formula = "=INDEX('[" & wb_pbef.Name & "]CORE_DATA'!L2:$L$" & drows & ",Sandbox!$D$1)"

This line of code populates the range of cells C6:c17 with the index formula forom a second source workbook. The data in column L of the source data worksheet is normally text, but often times holds nothing. (cell is empty).

For those empty cells, this formula leave a value of 0 (zero) in the destination cell.

How can I ensure that the target cell remains empty, rather than being populated with a zero when the source cell is blank?
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Conceptually, the following works.
Book1
ABCDE
1342
2020
3421 
Sheet1
Cell Formulas
RangeFormula
E1:E3E1=IF(INDEX($A$1:$A$3,C1,1)&""="","",INDEX($A$1:$A$3,C1,1))

It takes the INDEX result and adds "" to it so that it becomes a string, which, if empty returns "" whereas if 0 or any number will be false and then you can do the INDEX function. So, in the example above, E1 to E3 return the actual values, including E3, which is blank.
 
Upvote 0
Or, if you prefer:
=IF(ISBLANK(INDEX($A$1:$A$3,C3,1)),"",INDEX($A$1:$A$3,C3,1))
... will also do the trick.
 
Upvote 0
If the data is either text or blank, all you actually need to do to remove the 0 values is append an empty string:

Code:
.Range("C6:C17").Formula = "=INDEX('[" & wb_pbef.Name & "]CORE_DATA'!L2:$L$" & drows & ",Sandbox!$D$1)&"""""
 
Upvote 0
Thank you both. The support is most appreciated.
 
Upvote 0

Forum statistics

Threads
1,214,638
Messages
6,120,674
Members
448,977
Latest member
moonlight6

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top