Pivot and VB scripting range problem
Hi
What value shows for lastrow?
--
Regards
Roger Govier
"houghi" wrote in message
...
I get a 'Runtime error 1004'. Reference is not valid. With 'debug' the
whole line is yellow. When I change
!Range(Cells(2,1),cells(lastrow,5))
back to !R2C1:R37C5 then it works again.
Could it be that this not work because I work with Excel 2000? If that
is the case, is there a different solution?
Roger Govier wrote:
Hi
you could insert some code to find the lastrow
Dim lastrow as long
Lastrow = Cells(Rows.Count, 1).End(xlUp).row
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:=
_
"'Y:\\[Report.XLS]Sheet1'!Range(Cells(2,1),cells(lastrow,5))
_
).CreatePivotTable TableDestination:=Range("A4"),
TableName:="PivotTable1"
houghi
--
Knock-knock.
Who's there?
Under the Patriot Act, we don't have to tell you that.
|