我想将当前工作表中的单元格引用到另一工作表中的单元格并打印出来。我希望重复相同的过程,但将公式的参考单元格偏移一行零列,直到参考单元格为空。
ActiveCell.FormulaR1C1 = "=sheet2!R[2]C[1]"
ActiveWindow.SelectedSheets.PrintOut
ActiveCell.FormulaR1C1 = "=sheet2!R[3]C[1]"
ActiveWindow.SelectedSheets.PrintOut
ActiveCell.FormulaR1C1 = "=sheet2!R[4]C[1]"
ActiveWindow.SelectedSheets.PrintOut
答案 0 :(得分:0)
这吗?
此外,我不会依赖ActiveCell
。是否有要连续覆盖的特定单元格?在下面的代码中,我为每次迭代更改A1
,因此您需要将其更新为所需的单元格范围。
Sub PrintMe()
Dim ws1 As Worksheet: Set ws1 = ThisWorkbook.Sheets("Sheet1")
Dim ws2 As Worksheet: Set ws2 = ThisWorkbook.Sheets("Sheet2")
Dim LR As Long
LR = ws2.Range("A" & ws.Rows.Count).End(xlUp).Row
For i = 2 To LR
ws1.Range("A1").Value = ws2.Range("A" & i).Value
ws1.PrintOut
Next i
End Sub