Need a very simple macro to delete info in Excel sheets

RadioGeorge
RadioGeorge used Ask the Experts™
on
Simple help needed; having a brain drain!

I am using Microsoft Excel (old version, not 365--my projects are rather simple).

After I load a file, I go through it and delete certain lines.  I do this by:

1. Selecting the line or lines in the file I wish to delete.
2. Moving the cursor up to the options bar at the top (File, Edit, View, etc.).
3. Clicking on Delete from the drop-down menu that has opened.

I know that creating a macro (temporary or permanent) to do this is quite simple and did it myself a few years ago, but now, I just can't remember or easily dope out the ways to do it.

So, programmers, have at it and let me hear from you.

This IS easy, isn't it?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Subodh Tiwari (Neeraj)Excel & VBA Expert
Most Valuable Expert 2018
Awarded 2015

Commented:
To delete selected whole rows or whole columns, you only need a single line of code...

Sub DeleteSelectedRowsORColumns()
Selection.Delete
End Sub

Open in new window

RadioGeorgeOwner/Programmer

Author

Commented:
OK.....how do I use it on the spreadsheet?
Analyst Assistant
Commented:
Can't you right click and select Delete... to remove the rows you've selected?
Subodh Tiwari (Neeraj)Excel & VBA Expert
Most Valuable Expert 2018
Awarded 2015

Commented:
To implement this code, follow these steps...

  1. Open your workbook and press Alt + F11 to open VB Editor.
  2. On VB Editor --> Insert --> Module
  3. Paste the code into the opened Code Window.
  4. Close the VB Editor.
  5. Save your workbook as Macro-Enabled Workbook.

To run the code...

  1. Press Alt + F8
  2. Select the macro "DeleteSelectedRowsORColumns" from the available list of macros in the workbook.
  3. Click on Run to run the macro.
RadioGeorgeOwner/Programmer

Author

Commented:
Thanks to both experts!  The simple solution was a key fix and enabled me to finish my project quickly. The other, while suitable, just takes longer. Might be able to use i in the future.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial