Lookup Data Table with part of string

Hey, so I want to lookup a DT but the Strings I am searching with are only parts of the ColumNames I am searching for. So for example my variable I extracted is “020” but the column I am searching for is named “text (020)” and the other variable is a Name of a City but the columns include the postal Code and the City Name .

Hello plmrsch,

The easiest way to do it is by using the list of all the datatable name.
Afterwhat you can simply look through it and check if the item (datatable name) contains your extractedVar then you can use your Lookup Data Table inside the loop and use your result after.

Quick example :

Lets build a DataTable :
image

Then create a column list name with a assign :

columnList = (From dc In ExtractedDataTable.Columns.Cast(Of DataColumn)Select dc.ColumnName).ToArray()

And finaly loop through the column list, check if the item contains your extractedVar and lookup the datatable :
image image
Note: here extractedVar value is “020” and my result is a rowIndex value = 1. If I change the LookupValue to “col1val1” it returns me 0.

Hope it will help you :slight_smile:

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.