something easy for you

witamserdecznie

New Member
Joined
Jun 12, 2010
Messages
34
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

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
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

in your example

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!
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

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