Excel Query Data Remove

I forgot to edit the code @balkishan… Please change the path and sheet name before running the code

When you place the code in invoke code activity, go to manage packages and install microsoft.office.interop.excel

Don’t forget this

Installed bro,

So how do I give the range, specify the Path, and the Sheet Name? Please tell me bro. Can you please mention where I have to give the Path, Sheet Name, And Range?

Sorry for the delayed response @balkishan

Replace this with your path of the file , I mean give you entire path as “c:\hsdd\djsdj
filename.xlsm”

This with your sheet name :slight_smile:

And i have mentioned the dynamic range in the code if you see …

it will clear from 12th to the end

Thanks for the response bro.
So There is no RowCount variable, do I need to create this one. Or it’s there in the code.

I have declared and assigned the value in the code itself @balkishan. You don’t need to create one :slight_smile:

Okay Okay,

Please tell me what is this error bro

Fine
–lets go by basic and simple method
–use a excel application scope and pass the file path as input
–use a read range activity and get the output with a variable of type datatable
–use a for each row loop and pass the datatable variable as input
–inside the loop use a if condition like this
outdt.Rows.IndexOf(row)>=12
–then we can go for THEN part where we can use add to collections activity where in the collections mention as out_list and item as outdt.Rows.IndexOf(row)
where out_list is a list variable of type list(int32) with default value as new list(of integer) defined in the variable panel
–now next to this for each row loop use a for each loop and mention the input as out_list and change the type argument as int32 in the property panel
–inside this loop use a acticity called REMOVE DATAROW ACTIVITY where mention the row index as item and mention the datatable name
–now use a write range workbook activity next to this for each loop and mention the excel file path, sheetname and range as “” and datatable variable as well. Make sure that the ADD HEADERS property is enabled

hope this would help you
Cheers @balkishan

That was my mistake as I developed the code in a hurry :smile:

Replace the above line with

 Dim rowCount As Integer = ws.UsedRange.Rows.Count

I gave the range from A to G, change it to the final column value you have. If you have values till AZ , then the range will be “A12:AZ” + rowCount.ToString

Thanks @HareeshMR & @Palaniyappan it worked.

Taken 38 sec to deleted 1221 Rows data
image

Great
Cheers @balkishan @HareeshMR

Glad you got it @balkishan :blush:

Happy to help