Need to delete rows in multiple sheets simultaneously
Closed
ightbet
Posts
1
Registration date
Wednesday 29 May 2019
Status
Member
Last seen
29 May 2019
-
29 May 2019 à 23:53
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 3 Jun 2019 à 11:52
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 3 Jun 2019 à 11:52
Related:
- Need to delete rows in multiple sheets simultaneously
- How to delete a row in word - Guide
- Google sheets download - Download - Spreadsheets
- Google sheets right to left - Guide
- How to split excel sheet into multiple worksheets - Guide
- How to delete multiple files on mac - Guide
1 response
TrowaD
Posts
2921
Registration date
Sunday 12 September 2010
Status
Contributor
Last seen
27 December 2022
555
3 Jun 2019 à 11:52
3 Jun 2019 à 11:52
Hi Ightbet,
Not sure what you mean by "grouping the sheets", but by selecting all sheets (right-click a sheets tab, Select All Sheets) you can delete rows from all sheets.
But since it is fun to use VBA, here is a code which let you select a range, which is then converted to rows (so the range can be B5:B10, to delete rows 5:10) and then deleted from Sheet1, Sheet2 and Sheet3 (assuming those are actually the sheet names you used):
Even easier would be to select a range and then hit a shortcut to delete those rows from the 3 sheets.
To assign a shortcut, press Alt+F8 to display available macro's, select the macro and then click "Options".
Here is the code for that:
To implement the code(s), press ALT+F11, top menu "Insert", "Module", paste code(s) in the big white field.
Best regards,
Trowa
Not sure what you mean by "grouping the sheets", but by selecting all sheets (right-click a sheets tab, Select All Sheets) you can delete rows from all sheets.
But since it is fun to use VBA, here is a code which let you select a range, which is then converted to rows (so the range can be B5:B10, to delete rows 5:10) and then deleted from Sheet1, Sheet2 and Sheet3 (assuming those are actually the sheet names you used):
Sub RunMe()
Dim mRange As Range, mSheet As Worksheet
Set mRange = Application.InputBox("Select range", Type:=8)
Set mSheet = ActiveSheet
Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
Rows(mRange.Row & ":" & mRange.Row + mRange.Rows.Count - 1).Select
Selection.Delete
mSheet.Select
End Sub
Even easier would be to select a range and then hit a shortcut to delete those rows from the 3 sheets.
To assign a shortcut, press Alt+F8 to display available macro's, select the macro and then click "Options".
Here is the code for that:
Sub RunMe2()
Dim tRow, bRow As Integer, mSheet As Worksheet
Set mSheet = ActiveSheet
tRow = Selection.Row
bRow = Selection.Row + Selection.Rows.Count - 1
Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
Rows(tRow & ":" & bRow).Select
Selection.Delete
mSheet.Select
End Sub
To implement the code(s), press ALT+F11, top menu "Insert", "Module", paste code(s) in the big white field.
Best regards,
Trowa