Modern Design on VB, Windows Condition syntax

Hi there,

I have a workflow using excel
i would like to insert a column if this “industry” is not found in the column header.
under Use Excel file
i put a if condition as
Excel.Sheet(“Sheet1”).Address.Contains(“industry”)
but it is not working
the output turn out, it keep adding industry column
Note: i did not put read activity and did not put for each activity
image

Hi @YangYang ,
Could you please check your if condition
I have tried it work well
my input


my output

my condition
Excel.Sheet(“Sheet1”).Address.Contains(“industry”)

my code
InsertColumns.zip (123.1 KB)

regards,

@YangYang

Excel.sheet.Address will give the cell address or the range address of the sheet like A1:G23 etc and not check the value is present or not

Try like this in the if condition…this will read all the columns and check the column names contain industry or not

(From dc In Excel.Sheet("Sheet1").DataTableValue.Columns.Cast(Of DataColumn) Select dc.ColumnName).ToArray().Any(function(x) x.Trim.ToLower.Contains("industry"))

Cheers

Hi Anil_G,

it still insert industry even though there is this column.
(From DataColumn In Excel.Sheet(“Sheet1”).DataTableValue.Columns.Cast(Of DataColumn) Select DataColumn.ColumnName).ToArray().Any(function(x) x.Trim.ToLower.Contains(“industry”))

My update

InsertColumns.zip (66.1 KB)

Step 1 : Use Excel process scope followed by Use Excel file activities.
Step 2 : Use Read range activity and Store the Output

Range : Excel.Sheet("Sheet1")
Save to : DtReadInput | Variable Type -> System.Data.Datatable

Step 3: Use LookUp Range activity (Classic) Searches in a specified range for the coordinates of a cell.

Sheet Name : "Sheet1"
Value to search : “industry”
Output : Create an Output -> Lookup | Variable Type -> String

Step 3 : Use If activity to check the column is exist or not

Lookup.contains("")

Then -> Use  message box activity -> "not existed"
Else -> Use Insert activity

regards,