Next if blank in For Each Loop

A

achidsey

Excel Experts,

My spreadsheet is similar to the following:

1 2
A Symbol Div
B DELL 1.23
C IBM 0
D MSFT 1.50

For each symbol, if the amount in the Div column is not zero, I want to
perform a series of steps. If the amount is zero, I want to skip to the next
symbol.

In the code below, when I try to run it, Excel gives an error, highlights
the Next within the If statement and says I can not have a Next without a
For.

How do I edit this procedure to make it go to the next symbol if the amount
in the Div column is zero.

Sub AddDiv( )

Set Symbols = Range("B1:D1")

Set HDiv = Range("A2")

For Each Symbol in Symbols

If Cells(Symbol.Row, HDiv.Column).Value = 0 Then

Next Symbol

End If

(Rest of Procedure)

Next Symbol

End Sub

Thanks in advance,
Alan
 
D

Dave Peterson

Sub AddDiv( )

dim Symbols as Range
dim HDiv as range

Set Symbols = Range("B1:D1")
Set HDiv = Range("A2")

For Each Symbol in Symbols
If Cells(Symbol.Row, HDiv.Column).Value = 0 Then
'skip it
else
(Rest of Procedure)
end if
Next Symbol

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top