我正在用excel编写宏,以在一个工作簿中添加数据透视图。我试图在另一个工作簿上运行该宏。变量ACTST和ActWB获得正确的值。但是LastRow和LastCol变量将值设为0。有人可以告诉我哪里错了吗?
ACTST = ActiveSheet.Name
ActWB = ActiveWorkbook.Name
'Insert a New Blank Worksheet
On Error Resume Next
Set DSheet = Worksheets("Sheet1")
Worksheets("Sheet1").Activate
'Define Data Range
LastRow = DSheet.Cells(Rows.Count, 1).End(xlUp).Row
LastCol = DSheet.Cells(1, Columns.Count).End(xlToLeft).Column
Set PRange = DSheet.Cells(1, 1).Resize(LastRow, LastCol)