我尝试了以下失败。
Sub TestRange()
作为范围的昏暗示例
昏暗范围开始只要
昏暗范围结束只要
RangeStart = ActiveSheet.Cells(1,1)
RangeEnd = ActiveSheet.Cells(3,4)
将ws作为工作表
设置ws = Worksheets(“ Sheet5”)
使用ws
example = ws.Range("E" & .Rows.Count).End(xlUp).Row
Set example = Range(.Cells(RangeStart, 1), .Cells(RangeEnd, 8))
结尾为
示例。选择
Selection.Copy
结束子
答案 0 :(得分:0)
您缺少.
中的.Range
,它定义了With / End With块中的复制区域。
Dim example As Range
Dim RangeStart As Long, RangeEnd As Long
RangeStart = ActiveSheet.Cells(1, 1)
RangeEnd = ActiveSheet.Cells(3, 4)
With Worksheets("Sheet5")
'I don't know what the following is intended to do - it has no purpose
'example = ws.Range("E" & .Rows.Count).End(xlUp).Row
Set example = .Range(.Cells(RangeStart, 1), .Cells(RangeEnd, 8))
End With
example.copy