How to move data from an excel cell to unspecified number of rows

Hi everyone,

Below is the scenario I am trying to automate using UiPath studio. Screenshot below is sample data. I want to be able to move the Name ‘Wells Fargo’ to all rows under that client i.e. rows 3-8; and move the name ‘BOA’ to row 13.

Today we are doing everything else using UiPath on this file except for this one feature. I was wondering if and how there is an easy way to accomplish this.

Before:


Expected Output:

Hi @parimala.prata

Can you try this

Input:

Output:

Sequence.xaml (35.0 KB)

Regards,

Use below C# code in invoke code activity
where io_dt is In Out parameter of type DataTable

 DataTable dt = io_dt;
 dt.Columns.Add("Category"); 
	
string currentSection = "";  // Variable to track the current section
	try{
			foreach (DataRow row in dt.Rows)
            {
			
            // Check if the current row is a section header (i.e., column 3 (total) is null)
            if (string.IsNullOrEmpty(row[2].ToString()) && !string.IsNullOrEmpty(row[0].ToString()))
            {
				// Current row is a section header, set the section name from Invoice# (Column 0)
                currentSection = row[0].ToString();
				Console.WriteLine("currentSection: "+currentSection);
                continue; // Skip the section header itself
            }
		
            // Skip the second row of each section (i.e., the headers like "Invoice#", "Vendor", etc.)
            if (row[0].ToString() == "Invoice#")
            {
                continue;
            }
		
            // Set the value of  (Column 3) based on the section name
            if (!string.IsNullOrEmpty(currentSection))
            {
                row[3] = currentSection;  // Set Category in Column 3
				Console.WriteLine(row[3].ToString());
            }
			
        }
     }
		catch(Exception ex){
			Console.WriteLine(ex.Message);
			Console.WriteLine(ex.StackTrace);
		}
        
io_dt = dt;

hi Laxman,

I am trying this strategy on my end and will update you with the results. currently I am getting a miscount and mismatch.

I will keep you posted.

1 Like

hello Laxman,
For some reason, some mismatch seems to be happening and I am not able to pinpoint where. Any advice is greatly appreciated.

Main.xaml (24.5 KB)
Sample File.xlsx (11.6 KB)

Hi @parimala.prata

Can you try the below, i made some changes

Main.xaml (19.8 KB)

Output:

Sample File.xlsx (11.7 KB)

Regards,

1 Like

I cannot thank you enough. This solution is working like a charm. Thank you for your help and assistance.

1 Like

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