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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

macness

New Member
Joined
Jul 27, 2010
Messages
37
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!
 

witamserdecznie

New Member
Joined
Jun 12, 2010
Messages
34
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
Joined
Jul 27, 2010
Messages
37
Oops yeah that'll do it! i missed your declaration of xp = there...

Hoorah!
 

Watch MrExcel Video

Forum statistics

Threads
1,133,636
Messages
5,660,002
Members
418,541
Latest member
bugsoup

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