Hi All. Can you please enlighten me on how to stop this from erroring out because the sheet did not contain the search data. Thank you!
Code:
Dim wsb As Worksheet
Dim foundColb As Integer
Dim lastRowb As Long
Dim jb As Long
Dim accumb As Long
'sum cbcp totals and apply to totals tab
Sheets("BCPData").Activate
Set wsb = ActiveSheet
[COLOR=#ff0000]foundColb = wsb.Cells.Find("CBCP").Column
[/COLOR] lastRowb = wsb.Cells(Rows.Count, foundColb).End(xlUp).Row
For jb = 1 To lastRowb
If InStr(1, LCase(wsb.Cells(jb, foundColb)), "cbcp") > 0 Then
accumb = accumb + CLng(wsb.Cells(jb, foundColb + 1))
End If
Next jb
Sheets("Totals").Activate
Range("C59").Value = accumb * -0.01
Last edited: