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.
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]