error checking inside nested loop

knacksc2

Board Regular
Joined
Jan 23, 2014
Messages
63
Well, i am sure this looks silly, but why wouldn't this error checking method work when both cells are blank?

Code:
Sub Populate_Data()


Sheet3.Select
Dim a As Integer
a = Application.WorksheetFunction.CountA(Sheet3.Range(Cells(7, 1), Cells(1040000, 1)))


Sheet2.Select
For b = 1 To a


For c = 1 To 13


Sheet3.Cells(6 + b, (c * 7) - 5).Value = Application.WorksheetFunction.VLookup(Sheet3.Cells(6 + b, 1).Value, Sheet2.Range(Cells(7, 1), Cells(6 + a, 14)), c + 1, False)
Sheet3.Cells(6 + b, (c * 7) - 4).Value = Application.WorksheetFunction.VLookup(Sheet3.Cells(6 + b, 1).Value, Sheet2.Range(Cells(267, 1), Cells(266 + a, 14)), c + 1, False)


Dim var000 'check if there is an error in calculating hit rate
    var000 = Sheet3.Cells(6 + b, (c * 7) - 4).Value / Sheet3.Cells(6 + b, (c * 7) - 5).Value
    Dim iserr000 As Boolean
    iserr000 = IsError(var000)
    If iserr000 = True Then
    Sheet3.Cells(6 + b, (c * 7) - 3).Value = ""
    Else
    Sheet3.Cells(6 + b, (c * 7) - 3).Value = Sheet3.Cells(6 + b, (c * 7) - 4).Value / Sheet3.Cells(6 + b, (c * 7) - 5).Value
    End If


Next c
Next b


End Sub
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,223,910
Messages
6,175,320
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top