Formula Problem

dbrooks76

New Member
Joined
Sep 26, 2006
Messages
9
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

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
49,562
Office Version
  1. 365
Platform
  1. Windows
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.
 

dbrooks76

New Member
Joined
Sep 26, 2006
Messages
9
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 = -

The answers should be:
H16 = 0
H17 = 1
H18 = 1
H19 = 1
H20 = 1
H21 = 0

???
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
49,562
Office Version
  1. 365
Platform
  1. Windows
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
 

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707

ADVERTISEMENT

Or maybe:

=ISNUMBER(H16)+0


Richard
 

dbrooks76

New Member
Joined
Sep 26, 2006
Messages
9

ADVERTISEMENT

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!
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
49,562
Office Version
  1. 365
Platform
  1. Windows
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).
 

dbrooks76

New Member
Joined
Sep 26, 2006
Messages
9
Both the value cell and formula cell are categorised as "general".

Do I need change this?
 

Forum statistics

Threads
1,137,366
Messages
5,681,071
Members
419,950
Latest member
BeckiJae

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
Top