Need to copy the whole column value

Hi everyone,

I need to copy Column B & Column F or need to delete all the columns except the Column B & Column F from the excel.

Note: Copy/Paste range is taking more time.

Sample.xlsx (8.9 KB)

Could you help me to solve this?
Regards
Gokul

@lakshman @Palaniyappan @NIVED_NAMBIAR @postwick @prasath_S @ppr

Can anybody help?

1 Like

@Gokul001

Try below steps.

  1. First use Read Range activity to read the entire file and it will give output as DataTable. Let’s say ‘InputDT’.

  2. And then use multiple Delete Range activities to delete the data and pass Range as below.

    "A2:A"+(InputDT.Rows.Count+1).ToString
    "C2:E"+(InputDT.Rows.Count+1).ToString
     "G2:Z"+(InputDT.Rows.Count+1).ToString
    

Note: Replace Z with end column.

1 Like

Hi @lakshman

  • I attached only the sample xlsx file.
  • There are more columns in excel, so I want to delete all the columns after Column F.

Regards
Gokul

Hi

Did we try with custom component on this scenario

Cheers @Gokul001

2 Likes

@Gokul001

You can also try with Filter Datatable

Use Read range to read excel into Datatable

Later use Filter Datatable and in the outputColumns keep and use only required column names

This will remove remaining columns

Hope this may help you

Thanks

1 Like

Hi @Palaniyappan

I will look into it

1 Like

Hi @Srini84

I had tried to use Filter DataTable, but No Luck

Regards
Gokul

@Gokul001

Can you check what column names you are getting using output Datatable activity?

and use those column Names

Hope this may help you

Thanks

Hi @Srini84

Could you refer to the sample xlsx file?

Regards
Gokul

@Gokul001

Sorry I thought till F only. Take one more Delete Range activity and pass range as “G2”.

@lakshman

I will check it and come back

Sure @Gokul001

Hi @lakshman

Using “G2” is not working.

Regards
Gokul

@Gokul001

Do you know end column ? If yes then specify as below.

        "G2:Z"+(InputDT.Rows.Count+1).ToString

Note: Replace Z with end column.

1 Like

Hi,

Can you try to use DeleteRange and Insert/Delete Columns as the following?

Range property of DeleteRange will be

"G1:"+Uipath.Excel.Helpers.ExcelUtilities.ConvertColumnIndexToColumnLetter(dt.Columns.Count)+dt.Rows.Count.ToString

Change mode of Insert/Delete activity should be Remove.

Regards,

3 Likes

Hi @Gokul001

Try this approach

  1. Read the excel and store in dt1

  2. Then use

dt2= dt1.DefaultView.ToTable(False,{“Column B”,“ColumnF”})

  1. Then write dt2 in another sheet

Hope this helps you

Regards

Nived N :robot:

2 Likes

Dear Gokul,

You can look into the attached xaml for your requirement.
The xaml copies Column B and F and writes it into sheet2

ForumDivisionQuery.xaml (7.2 KB)

Thanks,
Geetishree Rao

1 Like

Thank You @Yoichi @Palaniyappan @geetishree.rao @NIVED_NAMBIAR @Srini84
@lakshman It’s Working for me.

Happy automation
Regards
Gokul

2 Likes

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