+ Reply to Thread
Results 1 to 15 of 15

Macro to Retain 10 rows from Row 10 up to before text like Total

  1. #1
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Macro to Retain 10 rows from Row 10 up to before text like Total

    I have sheets from "Bad Debts Recovered" onwards

    I need VBA Code to retain 10 rows on those sheets from this sheet up to last sheet where there is no data from row 10 in Col A up to the row before tect like Total is in Col A


    I have tried to write code to do this before it does nothing

    Kindly amend my code


    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    11-03-2023
    Location
    mutiple
    MS-Off Ver
    office 365
    Posts
    4

    Re: Macro to Retain 10 rows from Row 10 up to before text like Total

    Hello, please find below the code that I created, it works on any of those sheets and it starts from row 10:

    Please Login or Register  to view this content.

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,589

    Re: Macro to Retain 10 rows from Row 10 up to before text like Total

    Insert row(s) when less than 10?
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Re: Macro to Retain 10 rows from Row 10 up to before text like Total

    Hi Jindon


    Thanks for the help. The sheets that contain Data in Row 10 onwards In Col A op to text like "Total" can be ignored. I only want the macro to be applied to those sheets where there is no data in Rows 10 onwards in Col A up to one row before Text like "Total"

    It less than 10 rows, then insert rows as minimum must be 10 for row 10 up to row before Total

    Your code works perfectly on those sheets
    Last edited by Howardc1001; 11-04-2023 at 03:52 AM.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,589

    Re: Macro to Retain 10 rows from Row 10 up to before text like Total

    If you have row(s) that contains "total" before row 10 and ignore them then
    try change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Re: Macro to Retain 10 rows from Row 10 up to before text like Total

    Hi Mhdb

    Your code is only leaving one row after running the macro

    I need to retain a minimum of 10 blank rows on all sheets where the sheets contain no data in Col A10 up to before text like "Total"

    I have attached a workbook after running your code and another workbook of how it should look like after running the macro (What it should be)


    Kindly amend your code accordingly

  7. #7
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Re: Macro to Retain 10 rows from Row 10 up to before text like Total

    Thanks Jindon

    It works 100% on those sheets where there is no data in Col A from row 10 up to one row before Total

    Where any of the data has data in Col A10 onwards, these sheets must be left intact

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,589

    Re: Macro to Retain 10 rows from Row 10 up to before text like Total

    Not really sure,
    If this is not how you want, I need to see your workbook with before/after.
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Re: Macro to Retain 10 rows from Row 10 up to before text like Total


  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,589

    Re: Macro to Retain 10 rows from Row 10 up to before text like Total

    OK, see if this works,
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Re: Macro to Retain 10 rows from Row 10 up to before text like Total

    Many thanks Jindon


    This works 100%

  12. #12
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Re: Macro to Retain 10 rows from Row 10 up to before text like Total

    Hi Jindon


    On testing live data there are a few sheets that have more than 20 rows of data after A10

    I need your code amended so that if there is data 20 rows after A10 and it is before text like "Total", then those sheets containing data 20 rows after A10 ,but before text like "Total" are to remain intact

    Kindly amend your code per post # 10
    Last edited by Howardc1001; 11-07-2023 at 11:28 AM.

  13. #13
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Re: Macro to Retain 10 rows from Row 10 up to before text like Total

    I managed to amend your code see below and on checking it is working
    Please Login or Register  to view this content.

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,589

    Re: Macro to Retain 10 rows from Row 10 up to before text like Total

    If it is working as you want, that's nice.

    Good on you.

  15. #15
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Re: Macro to Retain 10 rows from Row 10 up to before text like Total

    Thanks Jindon. It is working 100%

+ 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. [SOLVED] Macro to Retain Last Duplicate In Col A where the text is similar
    By Howardc1001 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-06-2023, 12:01 PM
  2. [SOLVED] Macro to Retain specific Text
    By Howardc1001 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-30-2022, 10:09 AM
  3. [SOLVED] Macro to retain text after dash in Col C
    By Howardc1001 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-03-2021, 02:22 AM
  4. [SOLVED] Macro to retain text contain Email and to delete all other rows
    By Howardc1001 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-17-2020, 03:21 AM
  5. [SOLVED] VBA code to retain the rows with specific text.
    By mchilapur in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-09-2015, 04:15 AM
  6. Macro to retain rows by combining Max between 2 rows
    By Kartikjain13 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-10-2013, 04:32 AM
  7. Replies: 2
    Last Post: 12-18-2012, 05:22 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