+ Reply to Thread
Results 1 to 9 of 9

problem deleting 8 rows using macro

  1. #1
    Forum Contributor
    Join Date
    07-09-2013
    Location
    Dunedin, New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    105

    problem deleting 8 rows using macro

    Hi

    I have a simple spreadsheet with 4 rows per day for each day of the week - Monday through Sunday
    I wish to delete all Saturday and Sunday rows (8 at a time)

    I tried creating a macro but it doesn't produce the correct result

    I don't wish to resort the rows to delete Saturday and Sundays

    My macro basically starts on the first row of a Monday, step down to the first row of a Saturday, highlight the next 8 cells (left-hand column) and delete 8 rows

    Bob M
    Last edited by H28Sailor; 09-26-2014 at 07:51 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,421

    Re: Macro problem

    Start from the bottom and work your way up. So, from the bottom, work up to the last FRIDAY. Offset one row and resize the range to be 8 rows and delete them. Then work up to the next previous FRIDAY. Offset one row and resize the range to be 8 rows and delete them. And repeat until finished.

    If you start at the top, deleting rows will cause you to "jump over" rows that should be deleted.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2509 Win 11
    Posts
    24,992

    Re: Macro problem

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title go to your first post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Forum Contributor
    Join Date
    07-09-2013
    Location
    Dunedin, New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    105

    Re: Macro problem

    I must be doing something wrong as I get the same incorrect result

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,421

    Re: problem deleting 8 rows using macro

    Suggest that you post a sample workbook.

  6. #6
    Forum Contributor
    Join Date
    07-09-2013
    Location
    Dunedin, New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    105

    Re: problem deleting 8 rows using macro

    sample attached
    Attached Files Attached Files

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2509 Win 11
    Posts
    24,992

    Re: problem deleting 8 rows using macro

    Try this:

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    07-09-2013
    Location
    Dunedin, New Zealand
    MS-Off Ver
    Excel 2016
    Posts
    105

    Re: problem deleting 8 rows using macro

    Many thanks
    Works perfectly

    Bob M

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,421

    Re: problem deleting 8 rows using macro

    Just for the record, the method I was suggesting (with one small tweak):

    Please Login or Register  to view this content.

    I realised that I needed to check if it was the FIRST Friday before the weekend, not just any Friday

    Regards, TMS

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro Problem with VBA need Help (copy past cells with macro and message box)
    By Nissort in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-25-2013, 12:17 PM
  2. Problem using formulas within macro + problem with defined name.
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-11-2011, 04:39 AM
  3. Macro Problem - Having Original Macro Worksheet Open
    By Nosnum in forum Excel General
    Replies: 1
    Last Post: 12-03-2008, 03:21 PM
  4. Color Row Macro Problem, adapted from Patrick Malloy macro
    By SteveC in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-21-2006, 07:30 AM
  5. [SOLVED] Problem in updating all worksheets of a workbook using a macro that calls another macro
    By saai_ram@yahoo.com in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-20-2006, 01:25 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1