I am trying to have a program create several pivot tables for me (since I'd have to do this weekly/monthly) but same type of data.
Based on several websites, I copied some code and edited some code for the following:
Private Sub CommandButton1_Click()
'Declaration
'Creates new worksheet
Dim sht As Worksheet
Dim pvtCache As PivotCache
Dim pvt As PivotTable
Dim StartPvt As String
Dim SrcData As String
Dim DataRange As Range
'Create a new worksheet
  Set sht = Sheets.Add
  sht.Name = "EUPS Report"
'Determine the data range you want to pivot
  Set DataRange = Application.InputBox("Please Select the Data (Please select by pressing any cell in the table then pressing ctrl+a)", Default:=Selection.Address, Type:=8)
  SrcData = sht.Name & "!" & DataRange.Address(ReferenceStyle:=xlR1C1)
'Where do you want Pivot Table to start?
'  StartPvt = "'" & sht.Name & "!" & sht.Range("A15").Address(ReferenceStyle:=xlR1C1) & "'"
'Create Pivot Cache from Source Data
  Set pvtCache = ActiveWorkbook.PivotCaches.Create( _
    SourceType:=xlDatabase, _
    SourceData:=SrcData)
'Create Pivot table from Pivot Cache
  Set pvt = pvtCache.CreatePivotTable( _
    TableDestination:=Worksheets("EUPS Report").Range("A15"))
'   TableName:="PivotTable1")
End Sub
However, I'm running into this error:
Run-Time error '1004':
The PivotTable field name is not valid. To create a PivotTable report, you must use data that is organized as a list with labeled columns. If you are changing the name of a PivotTable field, you must type a new name for the field.
I cannot show you my data since it's company information, but it's a regular data table with column headers but no row headers. I have tested this code on other data but it doesn't work either. And I have tested my data with manually created pivot tables and they do work, so it's the code's problem.
Kindly let me know what's wrong. Thanks!