I'm very new to VBA and SQL, and I'm currently building a table to be uploaded to SQL onto Excel and using VBA. I want to essentially say if column I(Check Market) or J(Check m2)m2 have a value that says #NA then go no further and don't carry out the upload or the rest of the code. I think one of the problems might be I already have an IF loop - which is successful and has no errors associated with it.
I've tried loads of different code such as 'I(9):Check Market J(10):Check m2 'If I or J say #N/A then dont proceed with upload.
" and MARKET= " & _
"'" & sht.Cells(lRow, 9) & "'" & _
" and KPI_name= " & _
"'" & sht.Cells(lRow, 10) & "'"
If MARKET = sht.Cells(lRow, 9) And m2_name = sht.Cells(lRow, 10) Then ''Next and For (?) and Two If dont work
Else: MsgBox "Error"
If sht.Cells(lRow, 9) = "#N/A" BEGIN
MsgBox "Error in Column 'Check Market'"
Else If sht.Cells(lRow, 10) = "#N/A" BEGIN
MsgBox "Error in Column 'Check m2'"
If Range("I2:I11000").Value= "#NA" Then
Aucun commentaire:
Enregistrer un commentaire