something easy for you

witamserdecznie

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

Some videos you may like

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
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
31
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!
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,105,943
Messages
5,508,268
Members
408,673
Latest member
CELER_

This Week's Hot Topics

Top