Check for number of characters in a excel row

I have a row in an excel sheet called NUMBER. I’m using a for each and if statement to check every cell in the row and if that cell only has 7 characters or 5 then it will execute. How would i write the if statment? (if row.(“NUMBER”).ToString.contains 5 characters?)

Hi @NATHAN_MORA
I’d write:

row(0).ToString.Length = 5 or row(0).ToString.Length = 7

The 0 refers to Column A, you can change it to 1 for Column B, etc. or much better if the data table has headers and you can refer to them by name like
row(“NameOfColumn”).ToString.Length

1 Like

I Would add the method Trim before Length to eliminate Blanks

1 Like

how would you write that out?

im trying to eliminate empty spaces in the excel cells while looking searching cells that have only 7 characters in the cell

@NATHAN_MORA - if you could share a sample spreadsheet (by masking sensitive info) …we could take a look and assist.

1 Like

@NATHAN_MORA

To Trim the row value, you can use below code:

CurrentRow(“Numbers”).ToString.Trim.Count

Where “Numbers” is the column name.

1 Like

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