web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Error With Macro not r...
Power Automate
Answered

Error With Macro not running Properly

(0) ShareShare
ReportReport
Posted on by 19

Hi,

 

I'm learning to use power automate and I have an issue when trying to filter a pivot table with a Macro but when I call the Macro in power automate do not filter. When I run the Macro in excel VBA it works perfectly.
I Try renaming the macro, using parameters for the macro, killing all the Excel process.

 

 

 

Public Sub PivotsRefreshFilter()

 Sheets("Pivot").Select

 ActiveSheet.PivotTables("PivotTable1").ClearAllFilters
 
 ActiveSheet.PivotTables("PivotTable1").PivotFields("Filter").ClearAllFilters
 ActiveSheet.PivotTables("PivotTable1").PivotFields("Filter").CurrentPage = _
 "Last Closure"

End Sub

 

 

 

 

Flow.pngRun Macro.png

Thanks,

Terry S.

  • UK_Mike Profile Picture
    on at

    Make sure in " Launch Excel " that the macro setting is enabled...

  • TerrySchmidt Profile Picture
    19 on at

    Check is In place 

    Macro runs but do not perform the filter when running via power automate I add a check to write on a cell and that is done when running.

    - Running manually it filters and write the that "It Works"

    - Running in power automate does not filter but writes "It Works"

     

    Public Sub PivotsRefreshFilter()
    
     Sheets("Pivot").Select
    
     ActiveSheet.PivotTables("PivotTable1").ClearAllFilters
     
     ActiveSheet.PivotTables("PivotTable1").PivotFields("Filter").ClearAllFilters
     ActiveSheet.PivotTables("PivotTable1").PivotFields("Filter").CurrentPage = _
     "Last Closure"
     
     Range("E1").Select
     ActiveCell.FormulaR1C1 = "It Runs"
    
    End Sub

     

     

    Macros.png

     

    Regards,

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    This might be the stupidest thing, but try removing the ( ) at the end of the Macro name in Run Excel Macro...they shouldn't be needed.

  • TerrySchmidt Profile Picture
    19 on at

    Already try it, the weird part is that the last part of the macro that y put for control runs and write in the cell.

    When running manually from excel all the tasks are perform.

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    That's very weird.  The other option is to try running it through Send Keys:

     

    *be sure to set the time between keystrokes to 100...Excel needs a slight delay to not run over itself.  Notice the parenthesis are before the "w" because we don't want to hold alt down, just need to press alt and release before using the hotkeys to navigate the menu.

     

    Send keys {Alt}()wmv

    Wait (1)

    Send keys PivotsRefreshFilter{Enter}

     

    Good luck!

  • Verified answer
    TerrySchmidt Profile Picture
    19 on at

    It doesn't work, I delete and create all my file again from scratch and now it seems that is working. Maybe an issue with the original file that I create. 

  • UK_Mike Profile Picture
    on at

    Painful when you have to do it all again.

    Ive had issues before when calling a macro from the current workbook or the personal workbook, the name must be correct, im sure you double checked but it does happen.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 227 Super User 2026 Season 2

#2
David_MA Profile Picture

David_MA 213 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 151

Last 30 days Overall leaderboard