Consulting

Results 1 to 2 of 2

Thread: To set Date filter on pivot via input box when opening a file

  1. #1
    VBAX Newbie
    Joined
    Dec 2018
    Posts
    1
    Location

    To set Date filter on pivot via input box when opening a file

    Hi,
    I am new to VBA have error while trying to set pivot table date gives error "Run Time Error 1004 'Unable to get the PivotFields property of the PivotTable class' please help me solve this issue

    other than excel file contain other script with which I write in AutoOpen() so that it can do copy paste date while opening a this file also this file contain powerpivot and power query which am refreshing opening file please advise same code also not working workbook open()


    Dim DateSelect As String
        Dim PT As PivotTable
        Dim PF As PivotField
        Dim PI As PivotItem
    'Dim Inputdate As Date
    DateSelect = InputBox("Insert date in format mm/dd/yyyy", "Set Pivot Date", Format(Now(), "mm/dd/yyyy"))
    If IsDate(DateSelect) Then
    ThisWorkbook.Worksheets("PTHRPT").Select
            Set PT = Worksheets("PTHRPT").PivotTables("PivotTable6")
                PT.PivotFields("ActLoadEnd").ClearAllFilters
                PT.PivotFields("ActLoadEnd").PivotFilters.Add Type:=xlDateEqualTo, Value1:=DateSelect
    Else: MsgBox "Please insert date in correct format mm/dd/yyy", vbAbortRetryIgnore
    End If
    Attached Files Attached Files
    Last edited by Aussiebear; 12-13-2018 at 11:41 PM. Reason: Wrapped code with tags

  2. #2
    VBAX Mentor 大灰狼1976's Avatar
    Joined
    Dec 2018
    Location
    SuZhou China
    Posts
    479
    Location
    Hi Ziaullah!
    Attachment cannot be downloaded. Please confirm that the format or file size is correct.
    I guess the problem with code is that DateSelect is a String instead of a real DateValue. of course this is just my guess you know.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •