[英]Validation Excel before export to Access
Hey I have written a code that validate all the row of an excel sheet before nut I miss some points. 嘿,我写了一段代码来验证excel工作表的所有行,然后再说点错。 Here is the code
这是代码
Sub Validation_Trades()
Dim varTxt As String
Dim errTxt As String
Dim WS As Worksheet
Dim c As Long
Set WS = Worksheets("Trades")
c = 2
Do
varTxt = WS.Range("A" & CStr(c)).Value
errTxt = WS.Range("AP" & CStr(c)).Value
If varTxt = "" Then Exit Do
If Cells(c, 3) = "" Then errTxt = "Missing Ticket Number"
If Cells(c, 4) = "" Then errTxt = "Missing BRKR1"
If Cells(c, 5) = "" Then errTxt = "Missing BRKR2"
If Cells(c, 6) = "" Then errTxt = "Missing Trade Date"
If Cells(c, 7) = "" Then errTxt = "Missing Rec Time"
If Cells(c, 8).Value < Cells(c, 7).Value Then errTxt = "Wrong Sent Time"
If Cells(c, 9) = "" Then errTxt = "Missing Exec Time"
If Cells(c, 10) = "" Then errTxt = "Missing Cust Short Code"
If Cells(c, 12) = "" Then errTxt = "Missing Trader Initial"
c = c + 1
Loop
End Sub
If Cells(c, 3) = "" Then errTxt = "Missing Ticket Number" Then Exit Do
but 2 times Then doesn't work If Cells(c, 3) = "" Then errTxt = "Missing Ticket Number" Then Exit Do
但是2次则不起作用 If Cells(c, 13) <> Or("Y","N","") Then errTxt = "Wrong OATS"
but the OR statement doesn't have the good syntax If Cells(c, 13) <> Or("Y","N","") Then errTxt = "Wrong OATS"
但是OR语句语法不好 Thank you 谢谢
1. 1。
If Cells(c, 3) = "" Then
errTxt = "Missing Ticket Number"
Exit Do
End If
2. 2。
If varTxt = "" Then
errTxt = "Processed"
Exit Do
End If
3. 3。
Cells(c, 13) <> "Y" And Cells(c, 13) <> "N" And Cells(c, 13) <> "")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.