Jump to content
Macro Express Forums

Delete rows in an Excel file

Recommended Posts

I am trying to use the macro recorder, but when I select the first 6 rows of the spreadsheet and use the rows delete function it does not work when I play back the macro.

I have tried highlighting the rows and using the delete key, as well as right click and delete. When I play the macro back it does not select the rows and does not delete the rows. 

What am I missing? 

Link to comment
Share on other sites

Are you sure that the macro is even running?


As a FIRST step, look at the macro with the Script Editor and insert a Text Box Display command at the beginning, displaying some simple message like "Macro is running".  Then when you play back the macro you should see the message pop up on the screen.  Once you confirm that it actually runs, we can look into what it is and isn't doing. 

Link to comment
Share on other sites

General thoughts:

  • I don't like the macro recorder becasue I would experience similar frustration in cases like this. I advise all newbs to get into directly writing their macros as soon as possible. I advise you look at what it has recorded but also think of how you do it and write the code yourself. 
  • Avoid using the mouse.
  • Try writing a test macro as simple as possible that only attempts to do one thing. Keep it as simple as possible and make it independent. Then post it and a sample spreadsheet if necessary here so we can look at it and experiment. 
  • Check out F5 "Go To". 
  • Ctrl + Space selects and entire column, Shift + Space selects an entire row. Delete will delete the contents. 
  • Ctrl + Shift "+" inserts a row. Ctrl + [minus key] deletes the entire row. Click here.
  • In general, explore all the keyboard shortcuts in Excel. 


Link to comment
Share on other sites

Cory's Excel hotkeys are the same ones I use to automate spreadsheet tasks via Macro Express.


Think of the Macro Recorder as a tasty appetizer, but nutritionally empty. When I teach sessions on Macro Express, I mention the Recorder but the topic is never a course objective. Although it's possible to produce working macros viathe Recorder, the scripts are likely to be very fragile, especially when capturing mouse actions.

Link to comment
Share on other sites

19 minutes ago, acantor said:

tasty appetizer

LOL. Well put. 


Also I would add that I find that copying all a worksheet or exporting it, then processing it in ASCII File Process and pasting it back in or importing is easier. But of course that's not always an option. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...