Hello,
I want to count length in column Create ID by use if condition
If CurrentRow(“Create ID”).Tostring.Length<7
remark
But error : Object reference not set to an instance of an object.
I debug run output as below.
Please guide me for solve it.
Parvathy
(PS Parvathy)
July 2, 2024, 1:57am
2
Hi @fairymemay
Do you have empty cells in Create ID column?
Regards
@Parvathy yes, some row empty cell
@fairymemay ,
When the value of the column will be null or empty it will throw this error.
Try checking if it’s null first.
CurrentRow(“Create ID”) IsNot Nothing AndAlso Current Row(“Create ID”).Tostring.Length<7
Thanks,
Ashok
Parvathy
(PS Parvathy)
July 2, 2024, 2:02am
5
Hi @fairymemay
Try the below condition in If then:
If
Not String.IsNullOrEmpty(CurrentRow("Create ID").ToString()) AndAlso CurrentRow("Create ID").ToString().Length < 7
Then
' Add your logic here (e.g., set a remark or update a column)
End If
Hope it helps!!
Yoichi
(Yoichi)
July 2, 2024, 2:04am
6
Hi,
If you want to handle empty (null) as 0 length, the following will help you.
Current Row("Create ID") is Nothing OrElse Current Row("Create ID").Tostring.Length<7
Regards,
Yoichi
(Yoichi)
July 2, 2024, 2:13am
8
Please put Current Row(“Create ID”) is Nothing first, then connect with OrElse
@Yoichi Same error as below.
I have 3 condition in if condition
Parvathy
(PS Parvathy)
July 2, 2024, 2:25am
10
Hi @fairymemay
Check whether Create ID column name has any trailing spaces at the End,and try the below condition:
If
Not String.IsNullOrEmpty(CurrentRow("Create ID").ToString()) AndAlso CurrentRow("Create ID").ToString().Length < 7 AndAlso CurrentRow("Create ID").ToString.Equals("ESPGADMIN")
Then
' Add your logic here (e.g., set a remark or update a column)
End If
Regards
@Parvathy why use andalso in 3 condition ?
If morethan 1 condition I want go to then.
Please guide me for solve it.
Thank you.
Parvathy
(PS Parvathy)
July 2, 2024, 2:48am
12
Hi @fairymemay
Do you want the condition to go to then even if one of the conditions satisfy. Please specify.
Regards
@Parvathy I have 3 condition
blank
length <7
text = espgadmin
but If true condition (some or all condition) go to then
Parvathy
(PS Parvathy)
July 2, 2024, 3:00am
14
Hi @fairymemay
Can you share your excel file with all conditions. I will help you with flow.
Regards
@Parvathy Example file as attached.
input.xlsx (8.0 KB)
1 Like
Parvathy
(PS Parvathy)
July 2, 2024, 3:07am
16
Give me some time. I will help you with flow @fairymemay
Regards
1 Like
Parvathy
(PS Parvathy)
July 2, 2024, 3:50am
17
@fairymemay
Your requirement is to delete the row according to the three conditions.
Regards
@Parvathy Yes delete row in excel input that match condition.
rlgandu
(Rajyalakshmi Gandu)
July 2, 2024, 4:33am
19
@fairymemay
String.IsNullOrWhiteSpace(row("Create ID").ToString) OrElse row("Create ID").ToString.Length < 7 OrElse row("Create ID").ToString.Equals("espgadmin", StringComparison.OrdinalIgnoreCase)
Hope this works for you
1 Like
Parvathy
(PS Parvathy)
July 2, 2024, 4:34am
20
@fairymemay
=> Read Range Workbook
Output → dt
=> Use below syntax in Assign:
FilteredDt = (From row In dt.AsEnumerable()
Let createId = row.Field(Of Object)("Create ID").ToString()
Where Not (String.IsNullOrEmpty(createId) OrElse
(IsNumeric(createId) AndAlso createId.Length < 7) OrElse
createId.ToUpper() = "ESPGAMIN")
Select row).CopyToDataTable()
FilteredDt
is of DataType System.Data.DataTable
=> Write Range Workbook
Hope it helps!!
1 Like