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 / Range.AutoFilter not w...
Power Automate
Answered

Range.AutoFilter not working inside VBScript action PAD

(0) ShareShare
ReportReport
Posted on by 20

Hello, I have the following VBScript code and its not working inside a PAD flow I have. How I can debug this portion of code?

 

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("%ArchivoExcelCopia[0].FullName%")
objExcel.Visible = true
Set objWorksheet = objWorkbook.Worksheets("Micros")
objWorksheet.Activate
Set objRange = objWorksheet.Range("%Rango%")
objRange.Select
objRange.AutoFilter Field:=19, Criteria1:="TRUE"

  • Verified answer
    kinuasa Profile Picture
    801 Most Valuable Professional on at

    In VBScript, where you have named arguments such as 'Field:=', you need to replace the arguments in the order expected by the method, as shown below.

     

    objRange.AutoFilter 19, "TRUE"

     

    Also, As the Power Automate for desktop contains actions for using Excel, I suggest using the "Launch Excel" and "Set active Excel worksheet" actions to open workbook and select sheet.

     

    The code below is a sample flow, which you can copy and paste into flow designer.

     

    SET Rango TO $'''DataRange'''
    Folder.GetFiles Folder: $'''C:\\Test\\Excel\\Files''' FileFilter: $'''*.xls*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> ArchivoExcelCopia
    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: ArchivoExcelCopia[0].FullName Visible: True ReadOnly: False Instance=> ExcelInstance
    Excel.SetActiveWorksheet.ActivateWorksheetByName Instance: ExcelInstance Name: $'''Micros'''
    Scripting.RunVBScript VBScriptCode: $'''Dim objWorkbook
    Set objWorkbook = GetObject(\"%ArchivoExcelCopia[0].FullName%\")
    Dim objWorksheet
    Set objWorksheet = objWorkbook.ActiveSheet
    objWorksheet.Range(\"%Rango%\").AutoFilter 19, \"TRUE\"''' ScriptOutput=> VBScriptOutput

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

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 231 Super User 2026 Season 2

#2
David_MA Profile Picture

David_MA 217 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 170

Last 30 days Overall leaderboard