# something easy for you

#### witamserdecznie

##### New Member
Hi, something simple I believe. How to get into the below code a statement of this sort: if xp = 0 then go to next i?

Cheers

Code:
``````For i = 8 To 11
xp = Cells(i, 2): yp = Cells(i, 3)
DxfLine xp - dt, yp, xp + dt, yp, 1, ""
Next``````

### Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

#### macness

##### New Member
Construct it more like:

Code:
``````For i = 1 To 3

If Range("a1").Value = 1 Then
End If

If Range("a1") <> 1 Then
MsgBox ("Yay")
Else: MsgBox ("Boo!")
End If

Next i``````

Code:
``````For i = 8 To 11
if xp = 0 then
end if
if xp <>0 then
xp = Cells(i, 2): yp = Cells(i, 3)
DxfLine xp - dt, yp, xp + dt, yp, 1, ""
end if
Next i``````
that 'should' work!

#### witamserdecznie

##### New Member
Thanks,

That indeed works but has to be rearranged as shown below, otherwise macro does nothing.

Code:
``````For i = 8 To 11
xp = Cells(i, 2): yp = Cells(i, 3)
If xp = 0 Then
End If
If xp <> 0 Then
DxfLine xp - dt, yp, xp + dt, yp, 1, ""
End If
Next i``````

#### macness

##### New Member
Oops yeah that'll do it! i missed your declaration of xp = there...

Hoorah!