[英]VBA Range.Offset Error 1004 Range beyond scope of sheet Dynamic Range
When the schedule is new and empty, the offset moves beyond the scope of the sheet and gives error 1004. Needs a way to dynamically move up from the initially selected cell without error.当计划是新的且为空时,偏移量超出工作表的 scope 并给出错误 1004。需要一种方法来从最初选择的单元格动态向上移动而不会出错。 Some production lines drastically jump around the schedule which is why the offset up needs to be so great.一些生产线在时间表上大幅跳跃,这就是为什么需要如此大的偏移量。
Option Explicit
Sub Print_Line_3()
Dim lRow As Range
Application.ScreenUpdating = False
With Sheets("Line 3")
Set lRow = .Range("G1024").End(xlUp).Offset(-6, -6).Resize(24, 14)
lRow.PrintOut
End With
Application.ScreenUpdating = True
End Sub
' Starts from an arbitrary point then looks up to the last filled cell in that column.
' Moves from the selected cell up 6 then left 6 spots.
' Creates a selected range from previous cell to create a range to printout from.
Check the .Row
first:首先检查.Row
:
With Sheets("Line 3").Range("G1024").End(xlUp)
If .Row > 6 Then
Set lRow = .Offset(-6, -6).Resize(24, 14)
lRow.PrintOut
End If
End With
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.