我使用以下宏来在数据导入数据库之前对其进行按摩。标准是,列76或77中没有任何内容,第82列必须包含数字" 99"。如果满足所有这些标准,那么第6列需要说,"返回"。我得到错误的参数数量或无效的属性赋值错误。
Sub V_11()
Dim mySheet As Worksheet, myBook As Workbook 'Define your workbooks and worksheets as variables
Set myBook = Excel.ActiveWorkbook
Set mySheet = myBook.Sheets("Sheet1")
Dim i As Integer, j As Integer 'Define a couple integer variables for counting
j = 2
For i = 2 To mySheet.UsedRange.Rows.Count
If IsEmpty(mySheet.Cells(i, 76, 77).Value) And mySheet.Cells(i, 82) = "99" Then
mySheet.Cells(i, 6).Value = "Returned" ' . . . place the text "N/A" into the cell in row "j" in Sheet2.
End If
Next
End Sub
答案 0 :(得分:3)
mySheet.Cells(i, 76, 77).Value
不是有效的声明。
您需要将其分为2个if语句
If IsEmpty(mySheet.Cells(i, 76)) And IsEmpty(mySheet.Cells(i, 77)) And mySheet.Cells(i, 82) = "99" Then