Need a very simple macro to delete info in Excel sheets

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?
RadioGeorgeOwner/ProgrammerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
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

0
RadioGeorgeOwner/ProgrammerAuthor Commented:
OK.....how do I use it on the spreadsheet?
0
NorieAnalyst Assistant Commented:
Can't you right click and select Delete... to remove the rows you've selected?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
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.
0
RadioGeorgeOwner/ProgrammerAuthor 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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.