0
JNevillは非常に親切にクリーンアップしてマクロを改善しましたが、残念ながらエラーが発生して元に戻ってしまいました役職。うまくいけば、誰かが彼が中断したところで拾うことができます。Excel VBA - 範囲に応じて特定のシートにコピーするコードでエラーが発生しました
私は取得しています障害がある - オブジェクト変数またはWithブロック変数がそれを設定していないlastCell = Range("A" & Rows.Count).End(xlUp).Offset(1)
Sub Macro1()
'Make a variable to store the cell found
Dim lastCell as Range
'find the last cell in Column A of the active sheet
lastCell = Range("A" & Rows.Count).End(xlUp).Offset(1)
'Paste in the I16 value
lastCell.value = RangE("I16").value
'Grab whatever is hanging out in Column B next to the last cell and stick it in J20
Range("J20").value = lastCell.Offset(0,1).value
'Test to see if I16 has value "R"
If Range("I16").value = "R" Then
'Find the last row in Sheet7, Column B and store it to the variable
lastCell = Range("B" & Rows.Count).End(xlUp).Offset(1)
'Copy J20 value to the lastCell in Sheet 7, Column B
lastCell = Range("J20").value
End if
End Sub
オリジナルのポストはここにORIGINAL
おかげロリーは、そのが障害を停止していますが、気にしないならば、それはまだ、またsheet7 –
にそれを貼り付けていない、それが {Cを使用している文字に依存しに行く可能性が数枚を持っています} = sheet3 {P} = sheet1 {S} = sheet2 これもバインドに入れることができれば、idは最も感謝します –
このコードのどこかでSheet7を参照していないので、すべての「Range」呼び出しは、アクティブシート(コードが通常のモジュールにある場合)またはコードを含むワークシートのいずれかにデフォルト設定されます。 – Rory