Hi,
I am encountering a runtime error 13 on the first If statement on the following code -- it seems to run through the loop and then produces the error midway through. I haven't been able to find a solution.. still newish at vba so would be grateful for any suggestions! Many thanks!
Many thanks for any help!!
I am encountering a runtime error 13 on the first If statement on the following code -- it seems to run through the loop and then produces the error midway through. I haven't been able to find a solution.. still newish at vba so would be grateful for any suggestions! Many thanks!
Code:
Sub test()
Dim x as Integer
Dim i as Long
Dim t as Integer
x = Application.WorksheetFunction.CountIf(Sheet1.Range("A1:AV500"), True)
For i = 1 To 500
If Sheet1.Cells(i, 1) = True Then
Sheet1.Cells(i, 4).Copy
For t = 1 To x
If Sheet2.Cells(t, 1).Value = vbNullString Then
Sheet2.Cells(t, 1).PasteSpecial
End If
Next t
End If
Next i
End Sub