Hi,
I'm sure its something obvious but can't see it.
I want my code to select the sheet to use to create a Pivot Table based on the name thats in the Read Me worksheet, as this sheet name will vary.
The below works fine as a defined name
I have tried changing
to
but am getting a Type Mismatch
I'm sure its something obvious but can't see it.
I want my code to select the sheet to use to create a Pivot Table based on the name thats in the Read Me worksheet, as this sheet name will vary.
The below works fine as a defined name
VBA Code:
Dim mySourceWorksheet As Worksheet
Dim myDestinationWorksheet As Worksheet
Dim myPivotCache As PivotCache
Dim myPivotTable As PivotTable
'declare variables to hold source and destination range
Dim mySourceRange As Range
Dim myDestinationRange As Range
'identify source and destination worksheets. Add destination worksheet
With ThisWorkbook
Set mySourceWorksheet = .Worksheets("Sheet1")
Set myDestinationWorksheet = .Worksheets.Add(After:=.Sheets(.Sheets.Count))
myDestinationWorksheet.Name = "Temp"
End With
I have tried changing
Code:
Set mySourceWorksheet = .Worksheets("Sheet1")
to
Code:
Set mySourceWorksheet = Sheets("READ ME").Range("B5")
but am getting a Type Mismatch