嘿,我已经编写了一个代码来验证excel表的所有行,然后我会错过一些点。这是代码
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
但是2次然后不起作用If Cells(c, 13) <> Or("Y","N","") Then errTxt = "Wrong OATS"
,但OR语句没有良好的语法谢谢
答案 0 :(得分:0)
1
If Cells(c, 3) = "" Then
errTxt = "Missing Ticket Number"
Exit Do
End If
2
If varTxt = "" Then
errTxt = "Processed"
Exit Do
End If
3
Cells(c, 13) <> "Y" And Cells(c, 13) <> "N" And Cells(c, 13) <> "")