プロが教えるわが家の防犯対策術!

実行時エラー:1004が出て解決できません。どなたか教えて下さい。
作業はSh1(入力シート)からSh2(記録簿)に転記しますが、エラーが出て転記できない状態です。次のコードの「If sh2.Cells(row,"E").Value=sh1.Cells(5,"C").Value'名前」が黄色表示されます。
Sub 転記()
Dim sh1 As Worksheet
Dim sh2 As Worksheet
Dim maxrow As Long
Dim row As Long
Dim dicT As Object
Dim key As Variant
Set sh1 = Worksheets("交換入力シート")
Set sh2 = Worksheets("記録簿")
Set dicT = CreateObject("Scripting.Dictionary")
maxrow = sh2.Cells(Rows.Count, "C").End(xlUp).row
'一連番号を記憶
For row = 7 To maxrow
key = sh2.Cells(row, "C").Value
dicT(key) = row
Next
key = sh1.Cells(6, "AB").Value
If dicT.exists(key) = False Then
MsgBox ("一連番号=" & key & "は記録簿にありません")
Exit Sub
End If
If sh1.Cells(5, "C").Value = "" Then
MsgBox ("名前が未入力です")
Exit Sub
End If
If sh1.Cells(17, "L").Value = "" Then
MsgBox ("Aの枚数が未記入です")
Exit Sub
End If
If sh1.Cells(21, "L").Value = "" Then
MsgBox ("Kの枚数が未記入です")
Exit Sub
End If
If sh1.Cells(25, "L").Value = "" Then
MsgBox ("Gの枚数が未記入です")
Exit Sub
End If
If sh1.Cells(29, "L").Value = "" Then
MsgBox ("Hの枚数が未記入です")
Exit Sub
End If
If sh1.Cells(33, "N").Value = "" Then
MsgBox ("合計金額①が未入力です")
Exit Sub
End If
If sh1.Cells(17, "Z").Value = "" Then
MsgBox ("A1の枚数が未記入です")
Exit Sub
End If
If sh1.Cells(21, "Z").Value = "" Then
MsgBox ("K1の枚数が未記入です")
Exit Sub
End If
If sh1.Cells(25, "Z").Value = "" Then
MsgBox ("G1の枚数が未記入です")
Exit Sub
End If
If sh1.Cells(29, "Z").Value = "" Then
MsgBox ("H1の枚数が未記入です")
Exit Sub
End If
If sh1.Cells(33, "AB").Value = "" Then
MsgBox ("合計金額②が未入力です")
Exit Sub
End If
If sh1.Cells(35, "AB").Value = "" Then
MsgBox ("差額金額が未入力です")
Exit Sub
End If
If sh1.Cells(4, "M").Value = "" Then
MsgBox ("発行日が未記入です")
Exit Sub
End If
If sh1.Cells(17, "AF").Value = "" Then
MsgBox ("IDが未記入です")
Exit Sub
End If
row = dicT(key)
sh2.Cells(row, "E").Value = sh1.Cells(5, "C").Value '名前   ←ここが黄色くなります。
sh2.Cells(row, "Q").Value = sh1.Cells(35, "AB").Value '金額
sh2.Cells(row, "D").Value = sh1.Cells(17, "AF").Value 'ID
sh2.Cells(row, "B").Value = sh1.Cells(4, "M").Value '発行日
sh2.Cells(row, "F").Value = sh1.Cells(17, "L").Value 'A20
sh2.Cells(row, "G").Value = sh1.Cells(21, "L").Value 'k6
sh2.Cells(row, "H").Value = sh1.Cells(25, "L").Value 'G10
sh2.Cells(row, "I").Value = sh1.Cells(29, "L").Value 'H8
sh2.Cells(row, "J").Value = sh1.Cells(33, "N").Value '合計金額①
sh2.Cells(row, "L").Value = sh1.Cells(17, "Z").Value 'A21
sh2.Cells(row, "M").Value = sh1.Cells(21, "Z").Value 'K7
sh2.Cells(row, "N").Value = sh1.Cells(25, "Z").Value 'G11
sh2.Cells(row, "O").Value = sh1.Cells(29, "Z").Value 'H9
sh2.Cells(row, "P").Value = sh1.Cells(33, "AB").Value '合計金額②
MsgBox ("転記完了")
End Sub

質問者からの補足コメント

  • GOMAFU様 早速のご対応有り難う御座います。Activeでなくても良いです。

      補足日時:2018/01/30 20:41
  • つらい・・・

    どなたか解決方法を教えて下さい。お願いします。

      補足日時:2018/02/01 15:54

A 回答 (1件)

sh2は、Activeにしなくても良いんでしたっけ?

    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!