Prova così:

codice:
If foglio.Cells(i, 1).Value = num Then...