Related:
- Update of Copied Excel sheet
- Copying excel sheets - Guide
- Auto notify of email when excel sheet updated ✓ - Forum - Excel
- Copying data from one Excel sheet to another. ✓ - Forum - Excel
- Comparing Two Excel Sheets and copying like data to third sheet ✓ - Forum - Excel
- Auto notify or mail when excel sheet updated. ✓ - Forum - Excel
2 replies
TrowaD
Mar 21, 2019 at 12:47 PM
- Posts
- 2880
- Registration date
- Sunday September 12, 2010
- Status
- Moderator
- Last seen
- May 2, 2022
Mar 21, 2019 at 12:47 PM
Hi Vinayak,
Could you give the following code a try and see how that works out for you? Keep in mind that actions done by macro's can't be reversed by using the blue arrows, so better test this on a copy of your workbook.
Here is the code:
After pasting the code in a standard module, you can go back to Excel and hit Alt+F8 to display available macro's. Clicking on the options button will allow you to create a shortcut button. I used CTRL+d.
The rows or columns need to be connected.
Best regards,
Trowa
Could you give the following code a try and see how that works out for you? Keep in mind that actions done by macro's can't be reversed by using the blue arrows, so better test this on a copy of your workbook.
Here is the code:
Sub RunMe() Dim x, y As Integer, mCheck As Boolean, ws As Worksheet If Selection.Columns.Count > 16383 Then x = ActiveCell.Row y = Selection.Rows.Count ElseIf Selection.Rows.Count > 1048575 Then x = ActiveCell.Column y = Selection.Columns.Count mCheck = True Else Exit Sub End If For Each ws In Worksheets If mCheck = False Then ws.Rows(x & ":" & x + y - 1).Delete If mCheck = True Then ws.Select Range(Columns(x), Columns(x + y - 1)).Delete End If Next ws Sheets("Main").Select End Sub
After pasting the code in a standard module, you can go back to Excel and hit Alt+F8 to display available macro's. Clicking on the options button will allow you to create a shortcut button. I used CTRL+d.
The rows or columns need to be connected.
Best regards,
Trowa