+ Reply to Thread
Results 1 to 5 of 5

Deleting rows if one cell value is greater than the other.

  1. #1
    Registered User
    Join Date
    12-26-2015
    Location
    Las Vegas
    MS-Off Ver
    2013
    Posts
    56

    Deleting rows if one cell value is greater than the other.

    I attached the file and a pic of the formatting.

    Hi, new here. I have been playing with this macro for a week and am now in the final leg of my headache and need help. I came here because everyone seems so smart, quite impressive.

    I have a work related macro that I need to delete rows if the value of the cells in column A is greater than the cells in column B. That's it.

    The cells are formatted with HH:MM:SS AM/PM, but column A is actually the max allowed time of delivery and column B is the actual duration that took place. The file comes off of the server this way. I'm trying to filter for late deliveries and address them.

    Capture.PNG

    In this picture once the macro is working all of these rows would be deleted... there is thousands more in the attachment that need to be filtered through everyday.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    12-26-2015
    Location
    Paulding
    MS-Off Ver
    2007
    Posts
    3

    Re: Deleting rows if one cell value is greater than the other.

    I think your best bet would be to use mycell.value as follows

    For Each mycell In Range("A1:A10000")
    'mycell.replace What:="6:00:00 AM", Replacement:="21600"
    'mycell.replace What:="4:00:00 AM", Replacement:="14400"
    'mycell.replace What:="12:00:00 AM", Replacement:="43200"
    If mycell.Value > "4;00:00 AM" Then
    'now do replace function
    Stop
    End If
    Next


    You may need to format the value string to fit your needs.

  3. #3
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Deleting rows if one cell value is greater than the other.

    Very basic code in the attached.
    Essentially it adds a formula to column C to check if A > B and returns TRUE/FALSE.
    By filtering to TRUE and deleting those rows, what you're left with are just the FALSE.

    Simple but effective.

    BSB
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    12-26-2015
    Location
    Las Vegas
    MS-Off Ver
    2013
    Posts
    56

    Re: Deleting rows if one cell value is greater than the other.

    I tested it and it worked!

    YOU ARE THE MAN!!!

  5. #5
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Deleting rows if one cell value is greater than the other.

    Happy to help

    Thanks for the rep point.

    Don't forget to mark the thread as SOLVED if you're happy you have a working solution.

    BSB

+ 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. Copy rows to new sheet if value of cell entered greater than 1
    By shahzzy in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-19-2015, 12:09 PM
  2. [SOLVED] Deleting rows depending cell value
    By Liju144 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-04-2014, 05:50 AM
  3. Delete rows with cell values equal to or greater than current week number
    By Pradeep M B in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-22-2013, 09:39 AM
  4. Copy rows to new sheet if value of cell entered greater than 1
    By larryluv1 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 04-04-2013, 02:55 PM
  5. Deleting rows based on a value in a cell.
    By Polaris11 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-06-2011, 05:14 PM
  6. Replies: 0
    Last Post: 08-31-2010, 04:03 PM
  7. Deleting rows when a certain cell has a certain value
    By Leentje in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-28-2006, 11:51 AM

Tags for this Thread

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