With a little bit of imagination it can be done. Example
This will validate your "Parts" before attempting to export your data to DBA. You should change the ODBC Name, Sheet Name and Range.
Option Explicit
Public var_sql As String
Public Response As Integer
Public conn As New ADODB.Connection
Public rs As New ADODB.Recordset
Public cmd As New ADODB.Command
Public Sub USE_IT_TO_TEST()
'Test Run
MsgBox validate_sku
End Sub
Public Function validate_sku() As Boolean
Dim rng As Range
Dim row As Range
Dim cell As Range
Set rng = Sheets("Main").Range("C5:C100")
'CHANGE HERE For Each row In rng.Rows
For Each cell In row.Cells
If row.Value <> "" Then
var_sql = "SELECT Count(*) as CC FROM BKICMSTR WHERE BKIC_PROD_CODE='" & row.Value & "'"
If tc_tf(var_sql) = False Then
validate_sku = False
Response = MsgBox("Unable to Find SKU on DBA. ", vbCritical, " Saturn")
Exit Function
End If
'All entries on Sheet Are valid
validate_sku = True
End If
validate_sku = True
Next cell
Next row
End Function
Public Function tc_tf(the_sql As String) As Boolean
conn.CursorLocation = adUseClient
conn.Open "provider=MSDASQL;dsn=" & "DBA"
'CHANGE HERE rs.Open the_sql, conn, adOpenStatic
If rs("CC") <> 0 Then
tc_tf = True
Else
tc_tf = False
End If
rs.Close
conn.Close
End Function