# IF statement is not using correct values

#### EmPhetts

##### New Member
Hello,

I'm working on an Excel file to display the network class, subnet mask, etc. based on entered IP addresses.
An IF statement is giving me trouble and I'm pretty sure it's a simple rule or format I'm unfamiliar with.
With an IP of 192.168.1.1 in Cell A3, I used =FIND(".",A3,1) in Cell A1 to identify the location of the first decimal point and =MID(A3,1,A1-1) in Cell D1 to display the first octet, 192.
My issue is that when referencing Cell D1 to determine the address class, the IF statement is not displaying the correct result.

 A B C D E F G 1 4 8 10 192 168 1 1 2 IP Address Class N 3 192 4 192

<tbody>
</tbody>

For troubleshooting I tried the following...
1. Cell D2 =IF(D1=192,"Y","N")
2. Cell D3 =D1 [192 is aligned left in the cell]
3. Cell D4 192 [192 is aligned right in the cell]
When the IF statement in cell D2 references
· D1 N is displayed
· D3 N is displayed
· D4 Y is displayed
Can anyone tell me why the IF statement is working only with Cell D4?

### Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

#### rilzniak

##### Active Member
Try:

=VALUE(MID(A3,1,A1-1))

#### Tetra201

##### MrExcel MVP
Here is why:

Your formula =MID(A3,1,A1-1) returns "192" as a text string, not 192 as a number.

So, to make your IF work, it should be entered like this: =IF(D1="192","Y","N")

If you want 192 as a number in cell D1, you can use =--MID(A3,1,A1-1)

#### EmPhetts

##### New Member
That did the trick! Thank you so much for your help.

Replies
0
Views
320
Replies
3
Views
145
Replies
5
Views
382
Replies
0
Views
196
Replies
5
Views
653

1,190,741
Messages
5,982,692
Members
439,790
Latest member
jonaust

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