External vs. Local Address / Type Mismatch Error

pbornemeier

Well-known Member
Joined
May 24, 2005
Messages
3,915
I have been using a group of procedures for over a year and had made no changes to them. They ran fine on day X with one set of data, but on day X+1 it failed with a Run Time Error 13, Type mismatch (with a different set of data) on this line of code.
Code:
        ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
            Worksheets("Combined").Range("A1").CurrentRegion).CreatePivotTable _
            TableDestination:="", TableName:="xyzzy", DefaultVersion:=xlPivotTableVersion10
The code is in a standard module of Analysis v1.48.xlsm

I swapped to the old set of data and got no error, but when I examined the new set of data but could not see any error values or conditions that I could recognize as a reason for this error.

When that line of code is executing, the Combined worksheet is active.
I made the change suggested in this thread by Mike in post #2 (which was add .Address(,,,True) to the address) and the code worked again. Looking at the XL2007 object model entry for the 4th parameter of Range.Address:
External (Optional Variant) True to return an external reference. False to return a local reference. The default value is False.

When I examine the address with the External parameter set to False , I see:
$A$1:$AJ$2651
When it is set to True I see:
'[Analysis v1.48.xlsm]Combined'!$A$1:$AJ$2651

If the Combined worksheet is active, why would the code fail with the local version of the address?

I am in a corporate environment. Could some recent Excel 2007 update cause this?
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,224,522
Messages
6,179,292
Members
452,902
Latest member
Knuddeluff

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