+ Reply to Thread
Results 1 to 9 of 9

Delete rows based on two specific dates using a input box

  1. #1
    Registered User
    Join Date
    08-30-2017
    Location
    SHEFFIELD,ENGLAND
    MS-Off Ver
    2016
    Posts
    37

    Delete rows based on two specific dates using a input box

    Hi Guys,

    I have become unstuck and I desperately need you assistance once again :-)

    I need a VBA code that will do the following:-

    I have a data set, Row 1 contains table headers which will never change, column A contains dates (in UK Format dd/mm/yyyy) the list of dates will change daily I.e currently displays Jan 2018 - December 2018. Columns B - E contain the data.

    I want the VBA code to delete rows if the data falls between two date ranges located in column A.

    For example, with the current data I have a number of rows with data that falls in December 2018. I want to delete these rows out of the data set

    The code needs to be dynamic enough in a sense that I can change the dates to delete the rows by using a input box


    Any help as ever will much appreciated


    Slosh x

  2. #2
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: Delete rows based on two specific dates using a input box

    At a simple search you can find a lot of solutions to your problem. See here an example:

    https://www.ozgrid.com/forum/forum/h...ide-date-range

  3. #3
    Registered User
    Join Date
    08-30-2017
    Location
    SHEFFIELD,ENGLAND
    MS-Off Ver
    2016
    Posts
    37

    Re: Delete rows based on two specific dates using a input box

    Hi thanks for the heads up,

    from the link the below code works and I like it, but.....

    It doesn't pull in all the rows for the specific dates?

    i.e. when prompted by the input box, enter 15/05/2018 for both start and finish and only 41 rows are left after deleting everything else that sits outside this date range. However there are 73 rows of information that contains the 15th May 2018 in column A not 41 ?


    Please Login or Register  to view this content.
    any ideas ?


    Thanks

    Slosh

  4. #4
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: Delete rows based on two specific dates using a input box

    I've tested and it works for me. Maybe those are not 15th May dates? You can upload a sample, otherwise we can just guess.

  5. #5
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,204

    Re: Delete rows based on two specific dates using a input box

    Try change:

    Please Login or Register  to view this content.
    to:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    08-30-2017
    Location
    SHEFFIELD,ENGLAND
    MS-Off Ver
    2016
    Posts
    37

    Re: Delete rows based on two specific dates using a input box

    This line of code worked but the required results didnt happen

    Please Login or Register  to view this content.
    please see attached workbook for example


    Thanks again guys for you help


    Slosh
    Attached Files Attached Files

  7. #7
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,204

    Re: Delete rows based on two specific dates using a input box

    Change to:

    If .Cells(i, "A").Value >= dteStart And .Cells(i, "A").Value < (dteEnd +1)Then

  8. #8
    Registered User
    Join Date
    08-30-2017
    Location
    SHEFFIELD,ENGLAND
    MS-Off Ver
    2016
    Posts
    37

    Re: Delete rows based on two specific dates using a input box

    @phuocam absolute GENIUS !!!!!

    Worked a treat my friend

    very much appreciated for your time and willingness to help from the other side of the world !!!

    #power to the people

    Slosh x

  9. #9
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,204

    Re: Delete rows based on two specific dates using a input box

    You're welcome!

+ 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 specific range cell data based on user input
    By terriertrip in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-06-2017, 07:57 PM
  2. Create a specific number of consecutive rows based on row count input
    By goodlite in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-18-2017, 09:17 AM
  3. [SOLVED] Delete specific data from (x) new rows added as defined by user through input box
    By Jaysk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-10-2017, 12:41 AM
  4. delete rows on open based on input
    By leem in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-11-2013, 10:43 AM
  5. Delete rows based on multiple criteria using an input box
    By SteveGlaettli in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-10-2012, 01:44 PM
  6. Delete Rows Based on Dates, etc.
    By jlkirk in forum Excel General
    Replies: 12
    Last Post: 05-16-2011, 02:26 PM
  7. Delete rows based on user input
    By Militia in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-10-2009, 06:33 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