+ Reply to Thread
Results 1 to 13 of 13

Macro to Delete Values that are the same and ref is similar based in dates

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

    Macro to Delete Values that are the same and ref is similar based in dates

    I have References in Col D , Dates in Col E and values in Col G


    Where the Value in Col G in the prior Month is the same as the value in Col F relating to the last month and year in Col E eg June 2023 and ref in Col D is the same then delete these rows. Also if Diff in the values is within a tolerance of 050, then delete these rows


    I have highlighted the items to be deleted based on my specifications above

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

    Re: Macro to Delete Values that are the same and ref is similar based in dates

    try
    Please Login or Register  to view this content.

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

    Re: Macro to Delete Values that are the same and ref is similar based in dates

    Thanks for the help Jindon. Your code works 100%

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Macro to Delete Values that are the same and ref is similar based in dates

    Even though this requirement has been addressed, do you think that if such a perfect scenario occurs, should we still delete these three rows?
    Attached Images Attached Images
    Quang PT

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

    Re: Macro to Delete Values that are the same and ref is similar based in dates

    Thanks for the reply bebo021999

    If this scenario appears which is usually an adjusting entry, then all three rows can be deleted

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

    Re: Macro to Delete Values that are the same and ref is similar based in dates

    Quote Originally Posted by Howardc1001 View Post
    I have References in Col D , Dates in Col E and values in Col G
    Forgot about Col.D(ref) and delete if multiple rows.
    Please Login or Register  to view this content.
    Last edited by jindon; 07-21-2023 at 07:53 AM.

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

    Re: Macro to Delete Values that are the same and ref is similar based in dates

    Hi Jindon

    Kindly amend code

    Where Col I contains text like "Correcting" In Col I in the same row for the match items then these row must not be deleted

    I have highlighted the items in Yellow that must NOT be deleted

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

    Re: Macro to Delete Values that are the same and ref is similar based in dates

    Have you tried the code I last posted(#6)?

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

    Re: Macro to Delete Values that are the same and ref is similar based in dates

    Hi Jindon


    I tried post # 6. The items in blue to be deleted. The items in Yellow to remain intact is Col I contains "Correcting"

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

    Re: Macro to Delete Values that are the same and ref is similar based in dates

    Is this what you mean?
    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,725

    Re: Macro to Delete Values that are the same and ref is similar based in dates

    Hi Jindon

    This is exactly what I need-Many thanks indeed

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

    Re: Macro to Delete Values that are the same and ref is similar based in dates

    One thing I care is that when the multiple similar rows appear and if only one of them has "correcting" in col.I.

    The current code deletes only the row(s) without "correcting" in col.I, even other row has it.
    If you don't want to delete any row if one of the similar row has "correcting" somewhere then change to
    Please Login or Register  to view this content.

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

    Re: Macro to Delete Values that are the same and ref is similar based in dates

    Thanks for your valuable input and amended code

+ 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] Delete Rows where Narrative contains similar text and values sum to zero
    By Howardc1001 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-18-2021, 12:34 PM
  2. Looking for similar values and return separate tables / dates
    By zoomclub in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-06-2017, 05:44 PM
  3. [SOLVED] Calculating similar information/values as per two different dates
    By Anuru in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-22-2017, 07:18 AM
  4. Running Macro with Do Loop of similar based on values in a Column
    By fishycarl in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-11-2013, 03:50 AM
  5. [SOLVED] Help with macro to delete rows based on values
    By jimstrongy in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-26-2012, 08:49 AM
  6. VBA/Macro to delete rows based on comparing two dates?
    By tltlk678 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-26-2012, 02:25 AM
  7. Delete similar row based on condition
    By vijay2482 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-30-2010, 08:08 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