View Single Post
  #1   Report Post  
m5u4r3p2h1y m5u4r3p2h1y is offline
Junior Member
 
Posts: 4
Default Easy answers for anyone

Good afternoon, I am very new to VBA and was hoping if anyone code tell me why the following code only loops once. (I am just testing some stuff out in it). The message boxes are to see how many time it loops, but they both respond with 1.

Sub ref()

Dim RefNum(0 To 9) As String
Dim RefFound As Range
Dim wk As Workbook
Dim i, count As Integer


RefNum(0) = "100617"
RefNum(1) = "100203"
RefNum(2) = "105522"
RefNum(3) = "105774"
RefNum(4) = "105199"
RefNum(5) = "100514"
RefNum(6) = "105207"
RefNum(7) = "107065"
RefNum(8) = "101957"
RefNum(9) = "101394"

count = 0

Set wk = Workbooks.Open(ThisWorkbook.Path & "\2005 Hourly by Res cleaned.xlsx")
wk.Sheets("Hourly").Activate

For i = 0 To i = 9

Set RefFound = Cells.Find(What:=RefNum(i), After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
count = count + 1
Next
MsgBox (count)
MsgBox (i)
End Sub


Thanks in advance for answers