Filter Table.SelectRows from cell rang in sheet

Shayanan

New Member
Joined
Feb 11, 2021
Messages
8
Office Version
  1. 2019
Platform
  1. Windows
I Imported some data from folder. folder has 100 txt file. I need select txt file based on names listed in column2 at sheet2.

Originally they are selected manually in power query and code is like that:

VBA Code:
let

    Source = Folder.Files(Table.FirstValue(Excel.CurrentWorkbook(){[Name="FolderPath"]}[Content])),
    #"Filtered Rows" = Table.SelectRows(Source, each ([Name] = "TSLA.txt" or [Name] = "AAL.txt" or [Name] = "AAPL.txt" or [Name] = "ACST.txt" or [Name] = "ADTX.txt")),


but I want read value of cell in column2 sheet 2 (included TSLA,AAL,AAPL,ACST,ADTX), so if I changed value from TSLA to AZN, filter changed automatically and replace AZN.txt .
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi

File selection/Filter is hard coded like "TSLA.txt". There is other way around. You can add some common text in name of each file like TSLA PQR.txt , AAL PQR.txt.

Then apply filter like below. You can change file name but keep that common text (PQR) with the new name of that file. You can choose any common text. I choose PQR as an example. I hope it will help.

Power Query:
#"Filtered Rows" = Table.SelectRows(Source, each Text.Contains([Name], "PQR")),
 
Upvote 0

Forum statistics

Threads
1,214,875
Messages
6,122,044
Members
449,063
Latest member
ak94

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top