dnicholsby
New Member
- Joined
- Jan 24, 2017
- Messages
- 26
Hello,
I have written some code by I keep getting an error "Next without For". Any help appreciated:
I have written some code by I keep getting an error "Next without For". Any help appreciated:
Code:
Sub SelectStocks()
Dim i As Integer
Dim r As Integer
Dim region As String
Dim StockCount As Integer
Dim lastrow As Integer
Dim Ticker As String
Dim destCell As range
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 50 To 59
For r = 18 To lastrow
StockCount = Cells(38, i).Value
If StockCount = 0 Then Next i
region = Cells(17, i)
ElseIf Cells(1, r).Offset(0, 4) = region Then
If Cells(1, r).Offset(0, 17) <= StockCount Then
Ticker = Cells(1, r).Value
Set destCell = Worksheets("Stage 3").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
destCell.Value = Ticker.Value
End If
ElseIf Cells(1, r).Offset(0, 17) > StockCount Then Next i
End If
Next r
Next i
End Sub