Number = 85099055
Total=0
For Idx = 1 To 52
With Sheets(Idx).Cells
Set c = .Find(Number, .Cells(.Rows.Count, .Columns.Count), lookat:=xlWhole)
If Not c Is Nothing Then Total = Total + WorksheetFunction.Sum(c.Offset(0, 2).Resize(1, 7))
End With
Next
Dim oConn As Object
Dim oRs As Object
Dim strConnect As String
Dim strSQL As String
Dim ws As Excel.Worksheet
strConnect = vbNullString
strConnect = strConnect & "Provider=Microsoft.ACE.OLEDB.12.0;"
strConnect = strConnect & "Data Source="ThisWorkbook.FullName & ";"
strConnect = strConnect & "Extended Properties=""Excel 12.0 Xml;HDR=NO;IMEX=1"";"
Set oConn = CreateObject("ADODB.Connection")
For Each ws In ThisWorkbook.Worksheets
strSQL = vbNullString
'// F1 = column A
'// F2 = column B ect .. and so on
strSQL = strSQL & "SELECT F2, F3, F4, F5, F6, F7, F8 ......" & vbcrlf
strSQL = strSQL & "FROM [" & ws.Name & "$]" & vbcrlf
strSQL = strSQL & "WHERE F2 = ""85099055""" & vbcrlf '// column B
strSQL = strSQL & " OR F7 = ""85099055""" & vbcrlf '// column G
strSQL = strSQL & " OR F22 = ""85099055"";" '// column V
Set oRs = CreateObject("ADODB.Recordset")
oRs.Open strSQL, oConn
If Not(oRs.BOF and oRs.EOF) Then
'// recordset isn't empty, do something with datas
End If
oRs.Close
Set Ors = Nothing
Next
oConn.Close
Set oConn = Nothing
Notes:Number = 85099055
Total=0
For Idx = 1 To 52
With Sheets(Idx).Range("B8:B60,G8:G60,V8:V60")
Set c = .Find(Number, .Cells(.Rows.Count, .Columns.Count), lookat:=xlWhole)
If Not c Is Nothing Then Total = Total + WorksheetFunction.Sum(c.Offset(0, 2).Resize(1, 7))
End With
Next
EDIT Corrected code
pls try
Open in new window
Regards