Results 1 to 4 of 4

VBA to filter Data

Threaded View

  1. #1
    Registered User
    Join Date
    02-21-2017
    Location
    bloomfield, NJ
    MS-Off Ver
    2016
    Posts
    29

    VBA to filter Data

    Good Evening and thank you for coming to my Aid!

    I would like the data on worksheet "List of accounts" to filter and display only the newest date in "Column N". How can I add this at the end of my VBA?


    Sub Pivot_Refresh()

    Dim ws As Worksheet
    Set ws = Worksheets("List of all accounts")
    If ws.Application.WorksheetFunction.CountBlank(ws.Range("O2:O199")) > 0 Then
    MsgBox "There Are Blank Cells in Range O2:O199"
    Else

    Dim Table As PivotTable
    Set Table = ActiveSheet.PivotTables("PivotTable3")

    Table.RefreshTable

    Dim shtP As Worksheet
    Dim shtL As Worksheet
    Dim pt As PivotTable
    Dim pf As PivotField
    Dim pi As PivotItem
    Dim DateString As String
    Dim LRow1 As Long
    Dim LRow2 As Long

    Set shtP = Sheets("Pivot")
    Set shtL = Sheets("List of all Accounts")
    Set pt = shtP.PivotTables("PivotTable3")
    Set pf = pt.PivotFields("date")
    DateString = Format(Now(), "m/d/yyyy")
    LRow1 = shtL.Range("A" & Rows.Count).End(xlUp).Row + 1

    ActiveSheet.PivotTables ("PivotTable3")

    For Each pi In pf.PivotItems
    If pi.Value <> DateString Then
    End If
    Next pi

    shtL.Range("A2:O199").Copy shtL.Cells(LRow1, "A")

    LRow2 = shtL.Range("A" & Rows.Count).End(xlUp).Row

    If ws.Application.WorksheetFunction.Weekday(ws.Range("N2") + 1) = 6 Then
    shtL.Range("N2:N199").Value = shtL.Range("N2").Value + 4
    Else

    shtL.Range("N2:N199").Value = shtL.Range("N2").Value + 1
    End If

    shtL.Range("O2:O199").ClearContents

    MsgBox "Now Filter B1 to todays Date"
    End If

    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. using google sheets create filter tab does not filter importrange data correctly
    By western in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 0
    Last Post: 02-23-2021, 08:14 AM
  2. Filter data on sheet1 and show visible filter data on sheet 2 in colmn A
    By TAMMY32 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 01-25-2021, 09:35 PM
  3. Replies: 1
    Last Post: 04-23-2020, 03:44 PM
  4. VBA Advanced Filter - Two Filters Without Deleting Bottom Filter Data In Same Column Range
    By hysterical.useless in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-14-2017, 02:54 PM
  5. Replies: 1
    Last Post: 12-12-2014, 06:46 AM
  6. Replies: 0
    Last Post: 01-16-2014, 10:55 AM
  7. Replies: 2
    Last Post: 10-07-2013, 04:57 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1