1
두 장이 있습니다. WS2의 특정 열이 단어를 포함에있는 항목은 "UPDATE는"그것은 WS2에서 발견 된 새로운 데이터로 WS1을 업데이트 할 때Excel VBA : 형식 불일치 오류 13
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
을
미리 감사드립니다.
하면, 예를 들어 비교하고있는 셀 중 하나에 오류 값이있을 때이 오류가 발생하는 것을 추가 할 수 있습니다 "# N/A". VBA를 사용하면 오류 유형의 변형을 리터럴 문자열과 비교할 수 없습니다. – Tmdean
그래, 나는 그럭저럭 그것을 고칠 수 있었다. Dim checkstatus As String에 추가하고 checkstatus = CStr (ws2.Range ("AB"& CurRow) .Value)을 추가하여 값을 문자열로 만듭니다. 이제 작동합니다. – wh3resmycar2