[英]Excel VBA: type mismatch error 13
我有兩張。 當ws2中特定列中的條目包含單詞“ UPDATE”時,它將使用在ws2中找到的較新數據更新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
但是我在線上遇到類型不匹配的情況:
If ws2.Range("X" & CurRow) = "UPDATE" Then
提前致謝。
嘗試:
If ws2.Range("X" & CurRow).Text = "UPDATE" Then
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.