can't jump to 'activeworkbook' becuse it is hidden

sararose27

New Member
Joined
Aug 20, 2018
Messages
6
I am on a new laptop so maybe something needs to change so the macro can be used when I change laptops or provide to others.
The marco is used to create a pivot table based on data downloaded from PeopleSoft. The name of the file will always be different.
It's a bit different pivot table because I want the text where it would normally be numbers.
I found out how to do that using this link - Pivot Table With Text in Values Area
Thanks in advance for your help.

I'm getting the error above at this section of the code:
ActiveWorkbook.PivotCaches.Create(SourceType:=xlExternal, SourceData:= _
ActiveWorkbook.Connections( _
"WorksheetConnection_ActiveSheet!Table1"), Version _
:=8).CreatePivotTable TableDestination:="Sheet2!R3C1", TableName:= _
"PivotTable3", DefaultVersion:=8

The full code:
Sub Master_Contact_List()
'
' Master_Contact_List Macro

Dim MasterContactList As Workbook
Set MasterContactList = ActiveWorkbook
Dim ws As Worksheet
Dim rg As Range
Set rg = ActiveCell.CurrentRegion

Set ws = rg.Parent

Rows("1:1").Select
Selection.Delete Shift:=xlUp
Range("A1").Select
Application.CutCopyMode = False
ws.ListObjects.Add(xlSrcRange, rg, , xlYes).Name = _
"Table1"
Range("Table1[#All]").Select
Application.CutCopyMode = False
ActiveWorkbook.Connections.Add2 _
"WorksheetConnection_ActiveSheet!Table1", "", _
"WORKSHEET; ActiveSheet" _
, "sheet1!Table1", 7, True, False
Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlExternal, SourceData:= _
ActiveWorkbook.Connections( _
"WorksheetConnection_ActiveSheet!Table1"), Version _
:=8).CreatePivotTable TableDestination:="Sheet2!R3C1", TableName:= _
"PivotTable3", DefaultVersion:=8
Sheets("Sheet2").Select
Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable3")
.ColumnGrand = False
.HasAutoFormat = True
.DisplayErrorString = False
.DisplayNullString = True
.EnableDrilldown = True
.ErrorString = ""
.MergeLabels = False
.NullString = ""
.PageFieldOrder = 2
.PageFieldWrapCount = 0
.PreserveFormatting = True
.RowGrand = False
.PrintTitles = False
.RepeatItemsOnEachPrintedPage = True
.TotalsAnnotation = True
.CompactRowIndent = 1
.VisualTotals = False
.InGridDropZones = False
.DisplayFieldCaptions = True
.DisplayMemberPropertyTooltips = True
.DisplayContextTooltips = True
.ShowDrillIndicators = True
.PrintDrillIndicators = False
.DisplayEmptyRow = False
.DisplayEmptyColumn = False
.AllowMultipleFilters = False
.SortUsingCustomLists = True
.DisplayImmediateItems = True
.ViewCalculatedMembers = True
.FieldListSortAscending = False
.ShowValuesRow = False
.CalculatedMembersInFilters = True
.RowAxisLayout xlCompactRow
End With
ActiveSheet.PivotTables("PivotTable3").PivotCache.RefreshOnFileOpen = False
ActiveSheet.PivotTables("PivotTable3").RepeatAllLabels xlRepeatLabels
With ActiveSheet.PivotTables("PivotTable3").CubeFields("[Table1].[BU]")
.Orientation = xlRowField
.Position = 1
End With
ActiveWorkbook.Model.ModelMeasures.Add "HREmail", ActiveWorkbook.Model. _
ModelTables("Table1"), "CONCATENATEX(Table1,Table1,"", "")", _
ActiveWorkbook.Model.ModelFormatGeneral
ActiveSheet.PivotTables("PivotTable3").AddDataField ActiveSheet.PivotTables( _
"PivotTable3").CubeFields("[Measures].[HREmail]")
End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,214,904
Messages
6,122,169
Members
449,070
Latest member
webster33

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