Hello Guys
I used read range the Excel file and saved it as DT,
Then I try to use the input dialog to let the user input the ID they want.
I want to use if…then activity to tell the user whether can find the id or not in Excel, however, the expression seems incorrect in this case. Anyone can help ? Thanks
rlgandu
(Rajyalakshmi Gandu)
February 26, 2024, 5:53am
2
@CHAN_Hiu_Fung_Victor_Stud
exists = dt.AsEnumerable().Any(Function(row) row.Field(Of Integer)("Id") = inputId)
Give the Double if it gets the error even giving the Integer as datatype
exists = dt.AsEnumerable().Any(Function(row) row.Field(Of Double)("Id") = inputId)
@CHAN_Hiu_Fung_Victor_Stud ,
If your user input is in different datatype than string then use this:
dt.AsEnumerable().Any(Function(row) row.Field(Of String)(“Id”) = inputId.ToString)
Else use this:
dt.AsEnumerable().Any(Function(row) row.Field(Of [User Input Variable Data Type])(“Id”) = inputId)
Thanks,
Ashok
Parvathy
(PS Parvathy)
February 26, 2024, 6:03am
4
Hi @CHAN_Hiu_Fung_Victor_Stud
Try this:
=> Read Range Workbook
Output-> dt
=> Input Dialog Box:
Output-> ID
=> Use the below syntax in If condition:
If
dt.AsEnumerable().Any(Function(row) row.Field(Of Double)("ID") = Cdbl(ID))
Then
Msg Box-> Found
Else
Msg Box-> Not Found
End If
Regards
1 Like
rlgandu
(Rajyalakshmi Gandu)
February 26, 2024, 6:12am
6
@CHAN_Hiu_Fung_Victor_Stud
If my Solution works for you mark my thread as Solution,Please
1 Like
rlgandu
(Rajyalakshmi Gandu)
February 26, 2024, 6:17am
7
@CHAN_Hiu_Fung_Victor_Stud
For one post you are able to give one person as solution
Hello @Parvathy
I follow your steps but this error occurs. Do you know why?
Parvathy
(PS Parvathy)
February 26, 2024, 7:13am
9
Hi @CHAN_Hiu_Fung_Victor_Stud
Try this in If once:
dt.AsEnumerable().Any(Function(row) row.Field(Of String)("ID") = ID)
Regards
1 Like
It works! Thanks so much !!!
1 Like
Parvathy
(PS Parvathy)
February 26, 2024, 7:20am
11
You’re welcome @CHAN_Hiu_Fung_Victor_Stud
Happy Automation!!
system
(system)
Closed
February 29, 2024, 7:20am
12
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.