How do I find the next number in the series?

Hey All,

I have a column with series of numbers in it. How do I find the next number of “76007” as “76008” ?

image

@uio,

Iterate through the numbers and convert it to Int32. After this just increment it by 1 and that will be your next number.

Sample solution:

Output:
image

Thanks,
Ashok :slight_smile:

@uio

  1. Read Range activity: Read your Excel/CSV file and store the data in a DataTable variable (let’s call it dtNumbers).

  2. For Each Row activity:

    • Set the DataTable property to dtNumbers.
  3. Inside the For Each Row activity:

    • Use an If activity to check if the value in the specific column (let’s say it’s named “NumberColumn”) equals “76007”.
    • If the condition is true:
      • Assign activity: Increment the value in the “NumberColumn” by 1.
        (You can use the expression: Convert.ToInt32(row(“NumberColumn”)) + 1)
      • Write Line activity (optional): Display the next number.
  4. Write Range activity: Write the updated DataTable (dtNumbers) back to your Excel/CSV file.

Hi @uio ,

  1. Read your excel data and store it into the DT
  2. Take assign Activity and use the following expression.
    Nextnumber as string =
(Convert.ToInt32(Your_Dt.Rows(your_DT.Rows.Count - 1)("Registered Vendors")) + 1).tostring

Regards,
Vinit Mhatre

Hi @uio

Try this

(From row In DT.AsEnumerable() Select Convert.ToInt32(row("Registered Vendors"))).Max() + 1

Input:

image

Cheers!!

Can you please share the xaml file ? I’m getting an error “Assign: Value cannot be null. (Parameter ‘source’)”

Fails stating “Assign: Object reference not set to an instance of an object.”

@uio

Main.xaml (14.8 KB)

Cheers!!

Your file works fine. I think there’s some issue with my packages. Thanks a lot.

1 Like

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