Excel VBA:键入不匹配错误13

我有2张。 当在ws2中的特定列中的条目包含单词“UPDATE”时,它将使用在ws2中find的更新的数据来更新ws1

Private Sub CommandButton1_Click() Dim LastRow As Long, CurRow As Long, DestRow As Long, DestLast As Long Dim ws1 As Worksheet, ws2 As Worksheet Set ws1 = Sheets("Dashboard") Set ws2 = Sheets("TempHRI") LastRow = ws2.Range("B" & Rows.Count).End(xlUp).Row DestLast = ws1.Range("E" & Rows.Count).End(xlUp).Row For CurRow = 2 To LastRow 'Assumes first row has headers If ws2.Range("X" & CurRow) = "UPDATE" Then 'Column that looks up the word "Update" in ws2 If Not ws1.Range("E15:E" & DestLast).Find(ws2.Range("B" & CurRow).Value, LookIn:=xlValues, LookAt:=xlWhole) Is Nothing Then DestRow = ws1.Range("E15:E" & DestLast).Find(ws2.Range("B" & CurRow).Value, LookIn:=xlValues, LookAt:=xlWhole).Row End If ws1.Range("Q" & DestRow).Value = ws2.Range("N" & CurRow).Value 'assumes supervisor is in column C in both sheets ws1.Range("R" & DestRow).Value = ws2.Range("O" & CurRow).Value 'assumes director is in column D in both sheets End If Next CurRow End Sub 

但我得到一个types不匹配:

If ws2.Range("X" & CurRow) = "UPDATE" Then

提前致谢。

尝试:

 If ws2.Range("X" & CurRow).Text = "UPDATE" Then