ActiveWorkbook.Queries.Add Filter Criteria

jyothis89

New Member
Joined
Sep 29, 2018
Messages
1
Hello,
I have a code in which i use ActiveWorkbook.Queries.Add to import a CSV file. But while importing i need to filter only those rows containing value given by user. Below is the code. I have Highlighted and Bold the portion where i give the filter criteria as [Object ID] = 140. But what i want is, instead of [Object ID] = 140, I want Object ID = xObjID, where xObjID is input taken from user xObjID = InputBox(“Enter Object ID”). But its not working. Is there any alternative. Please help.

Code:
[COLOR=#555555][FONT='inherit']ActiveWorkbook.Queries.Add Name:=”S2KVTQ_VTQTimeTable”, Formula:= _[/FONT][/COLOR]
[COLOR=#555555][FONT='inherit']        “let” & Chr(13) & “” & Chr(10) & ”    Source = Csv.Document(File.Contents(“”” & xFileName & “””),[Delimiter=””,””, Columns=6, Encoding=1252, QuoteStyle=QuoteStyle.None]),” & Chr(13) & “” & Chr(10) & ”    #””Changed Type”” = Table.TransformColumnTypes(Source,{{“”Column1″”, Int64.Type}, {“”Column2″”, Int64.Type}, {“”Column3″”, type number}, {“”Column4″”, type datetime}, {“”Column5″”, type nu” & _[/FONT][/COLOR]
[COLOR=#555555][FONT='inherit']        “mber}, {“”Column6″”, Int64.Type}}),” & Chr(13) & “” & Chr(10) & ”    #””Removed Other Columns”” = Table.SelectColumns(#””Changed Type””,{“”Column2″”, “”Column3″”, “”Column4″”}),” & Chr(13) & “” & Chr(10) & ”    #””Renamed Columns”” = Table.RenameColumns(#””Removed Other Columns””,{{“”Column2″”, “”Object ID””}, {“”Column3″”, “”Value””}, {“”Column4″”, “”Date & Time””}}),” & Chr(13) & “” & Chr(10) & ”    #””Filtered Rows”” = Table.SelectRows(#””Rename” & _[/FONT][/COLOR]
[COLOR=#555555][FONT='inherit']        “d Columns””, each [B]([Object ID] = 140)[/B])” & Chr(13) & “” & Chr(10) & “in” & Chr(13) & “” & Chr(10) & ”    #””Filtered Rows”””[/FONT][/COLOR]
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,214,870
Messages
6,122,021
Members
449,060
Latest member
LinusJE

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