Site icon Kaizen.Personal computer work.

How to delete multiple rows/columns in Excel.(Power Automate Desktop)

Japanese version.

Introduces how to delete multiple rows or multiple columns in an Excel book.

There are two ways of deleting: Delete one line at a time and Delete all at once.

Deleting in batches is faster, but it involves keystrokes, so it may fail due to the user's mouse or keystrokes.

Deleting one line at a time takes longer, but it is stable because there is no key operation. Also, the flow is easy to understand.

If the execution time is not a problem, delete one line at a time.
If it is too slow, it is better to delete them all at once.

Overall view of Flow

Delete one row at a time

Delete one column at a time

Delete all rows at once

Delete all columns at once

Robin(for copy and paste)

Delete one row at a time

Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\Test\\Test.xlsx''' Visible: False ReadOnly: False Instance=> ExcelInstance
Excel.SetActiveWorksheet.ActivateWorksheetByName Instance: ExcelInstance Name: $'''Sheet1'''
SET Start TO 3
LOOP LoopIndex FROM Start TO 6 STEP 1
    Excel.DeleteRow Instance: ExcelInstance Index: Start
END
Excel.CloseExcel.CloseAndSave Instance: ExcelInstance

Delete one column at a time

Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\Test\\Test.xlsx''' Visible: False ReadOnly: False Instance=> ExcelInstance
Excel.SetActiveWorksheet.ActivateWorksheetByName Instance: ExcelInstance Name: $'''Sheet1'''
SET Start TO 3
LOOP LoopIndex FROM Start TO 6 STEP 1
    Excel.DeleteColumn Instance: ExcelInstance Column: Start
END
Excel.CloseExcel.CloseAndSave Instance: ExcelInstance

Delete all rows at once

Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\Test\\Test.xlsx''' Visible: True ReadOnly: False Instance=> ExcelInstance
Excel.SetActiveWorksheet.ActivateWorksheetByName Instance: ExcelInstance Name: $'''Sheet1'''
Excel.SelectCellsFromExcel.SelectCells Instance: ExcelInstance StartColumn: 1 StartRow: 3 EndColumn: 16384 EndRow: 6
MouseAndKeyboard.SendKeys.FocusAndSendKeys TextToSend: $'''{LControlKey}({Subtract})''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
Excel.CloseExcel.CloseAndSave Instance: ExcelInstance

Delete all columns at once

Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\Test\\Test.xlsx''' Visible: True ReadOnly: False Instance=> ExcelInstance
Excel.SetActiveWorksheet.ActivateWorksheetByName Instance: ExcelInstance Name: $'''Sheet1'''
Excel.SelectCellsFromExcel.SelectCells Instance: ExcelInstance StartColumn: 3 StartRow: 1 EndColumn: 6 EndRow: 1048576
MouseAndKeyboard.SendKeys.FocusAndSendKeys TextToSend: $'''{LControlKey}({Subtract})''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
Excel.CloseExcel.CloseAndSave Instance: ExcelInstance

Flow creation steps

Delete one row/column at a time

Set up a Launch Excel Action.

ParameterValue
Launch Exceland open the following document
Document pathPath of the target Excel book.
Make instance visibleOFF
Open as ReadOnlyOFF

Set up a Set active Excel Worksheet Action.

ParameterValue
Active worksheet withName
Worksheet nameThe name of the target sheet.

Create the variable %start% to specify the initial number of rows or columns to start deleting.

Set up a Loop.

ParameterValue
Start from%start%
End toNumber of rows or columns to finish deleting.
Increment by1

Set up a Delete row from Excel worksheet or Delete column from Excel worksheet in the Loop.

ParameterValue
Delete row/column%start%

Finally, set up a Close Excel Action and save the file.

After Flow execution
After Flow execution

Delete all rows/columns at once

Set up a Launch Excel Action.

ParameterValue
Launch Exceland open the following document
Document pathPath of the target Excel book.
Make instance visibleON
Open as ReadOnlyOFF

Set up a Set active Excel Worksheet Action.

ParameterValue
Active worksheet withName
Worksheet nameThe name of the target sheet.

Set up a Select Cells in Excel worksheet.

ParameterValue
SelectRange of cells
Start column1
Start rowStart row to be deleted.
End column16384
End rowLast row to be deleted.
To delete rows.
ParameterValue
SelectRange of cells
Start columnStart column to be deleted.
Start row1
End columnLast column to be deleted.
End row1048576
To delete columns.

Set up a Send Keys and specify the - (minus) key qualified with the CTRL key.

{LControlKey}({Subtract})

Finally, set up a Close Excel Action and save the file.

For those who want to learn Power Automate Desktop effectively


The information on this site is now available in an easy-to-read e-book format.

Or Kindle Unlimited (unlimited reading).

You willl discover how to about basic operations.

By the end of this book, you will be equipped with the knowledge you need to use Power Automate Desktop to streamline your workflow.

Links

Tips(Power Automate Desktop)

Exit mobile version