Invalid procedure call or argument Error "5"

firebolt

New Member
Joined
Jul 28, 2011
Messages
15
I encounter the error message "invalid procedure or argument" error 5. What does mean?

I try to ask excel to create a pivot table on the Active Sheet. It goes to a new sheet, but it does not create a pivot table. It prompts me for Error 5.

Could you please help to resolve this ?

Below is the VBA CODE:

Sub AutoPivtbl()
Dim lastrow As Long, LastCol As Integer, i As Long, iStart As Long, iEnd As Long
Dim Newsheet As Worksheet
Application.ScreenUpdating = False
With ActiveSheet
lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
LastCol = .Cells(1, Columns.Count).End(xlToLeft).Column
.Range(.Cells(1, 1), Cells(lastrow, LastCol)).Select
Set Newsheet = Sheets.Add(Type:=xlWorksheet)
For i = 1 To Sheets.Count
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"2!R1C1:R3C8", Version:=xlPivotTableVersion12).CreatePivotTable _
TableDestination:="sheet(Newsheet)!R3C1", TableName:="PivotTable.count", DefaultVersion _
:=xlPivotTableVersion12
Next i
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,224,583
Messages
6,179,673
Members
452,937
Latest member
Bhg1984

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top