# Formula Problem

#### dbrooks76

##### New Member
Hi,

I'm trying to get a spreadsheet to read a formula that will return a dash (-) as a zero (0) whilst any other number, including zero (0), is to be returned as a one (1).

My current formula reads a dash and zero both as zero's and so returns the wrong answer.

=IF(H16="-",1,0)
if true = 1
if false = 0

Any idea's how I can prevent this?

Cheers,

Dave

### Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
dbrooks76

Welcome to the Mr Excel board!

I may not have understood correctly, but I think you just need to swap the 0 and 1 in your formula. Try this:
=IF(H16="-",0,1)

If this is not it please give a few examples of data and expected results.

Tried That!

Hi,
thanks for quick reply. But I've tried that and it throws the zero figures back as a zero.
I'm after any number to be returned as a one (1) and any dashes (-) to be zero.

So if:
H16 = -
H17 = 2.0
H18 = 2.3
H19 = 0
H20 = 1.2
H21 = -

H16 = 0
H17 = 1
H18 = 1
H19 = 1
H20 = 1
H21 = 0

???

dbrooks76

Your last post lists the answers in the same cells as the original data. I assume that was a mistake and the results are to be in an adjacent cell. If not post back.

Here is my sheet with the formula in I16 (copied down): =IF(H16="-",0,1)
Mr Excel.xls
GHIJ
15
16-0
1721
182.31
1901
201.21
21-0
22
Sheet1

Or maybe:

=ISNUMBER(H16)+0

Richard

Is it a dash that is being displayed, or is it a zero formatted as accounting with no currency?

The dash is where no value is known. and the zero's are actual values (where present).

Strangely just tried the formula on a new spreadsheet and it works, but the company spreadsheet doesn't!! Weird!! I think i'm stepping into bigger problems...!!!

Thanks for all your help though guys!

Strangely just tried the formula on a new spreadsheet and it works, but the company spreadsheet doesn't!! Weird!!
On the company spreadsheet, select H16 and then go Format|Cells...|Number What category is the cell formatted as?
Do the same on cell I16 (or wherever the formula is located).

Both the value cell and formula cell are categorised as "general".

Do I need change this?

You shouldn't need to change that - General is fine

Replies
10
Views
535
Replies
15
Views
484
Replies
2
Views
528
Replies
6
Views
925
Replies
2
Views
113

1,218,750
Messages
6,144,281
Members
450,535
Latest member
Erlull

### 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.

### Which adblocker are you using?

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

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