Execute Macro can‘t work as expected

image
Dim a As Long
a = Cells.SpecialCells(xlLastCell).Row
Rows(10 & “:” & a).Select
Selection.Delete shift:=xlUp
image
It dosen’t work. can’t delete any row.
What’s the matter?
Thanks

2 Likes

Can you check the properties of Excel Application Scope.
Make sure that read-only option is not checked. Copy option is not checked.

And also update the code to delete the cells for a particular sheet as below -

Dim a As Long
a = Sheet1.SpecialCells(xlLastCell).Row
Sheet1.Rows(10 & ":" & a).Delete shift:=xlUp

Regards,
Karthik Byggari

3 Likes

good job

What’s the matter?
" Rows(10 & “:” & a).Select
Selection.Delete shift:=xlUp" works with excel but didn’t work in uipath.
But your code works with both excel and uipath
What’s the matter?

1 Like

The process is running in the background, the selection of cells is in a question.
So instead of selecting the cells, it is recommended and a good practice to use direct reference.

1 Like

Thanks


I have alreadey choosed this parameter,is the process also running in the background?

1 Like

No. The process runs in the foreground in this case. But sometimes the excel processes doesn’t work as expected because of it is triggered from other applications or the selection may change once the excel loses the focus because of interchanging applications.

Regards,
Karthik Byggari

1 Like

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