+ Reply to Thread
Results 1 to 8 of 8

Delete cell values with Date function in vba

  1. #1
    Registered User
    Join Date
    12-26-2019
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    69

    Delete cell values with Date function in vba

    Hi all,

    i have the following code in a module:

    Please Login or Register  to view this content.
    If cell A1 has today's date it will delete the cell value in B1.
    It works fine however, I want to have it for 5 more rows.
    I tried Range("A1:A5") which suppose to delete the values in B1:B5 but it doesn't.
    Basically, what I would like is if eg. A3 has today's date then it will delete the cell value in B3.
    If A4 has today's date then it will delete the cell value in B4
    I have attached a sample file.
    The real workbook i have has more than 10000 rows, for this example i just kept it with 5 rows.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Delete cell values with Date function in vba

    Please Login or Register  to view this content.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    12-26-2019
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    69

    Re: Delete cell values with Date function in vba

    Hi mehmetcik,
    that's so cool.
    Thank you so much.
    How can i also delete B column? Currently it only deletes A column.

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try this !


    According to your attachment a VBA beginner starter demonstration :

    PHP Code: 
    Sub DeleteDates()
        [
    B1:B5] = [IF(A1:A5=TODAY(),"",B1:B5)]
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Delete cell values with Date function in vba

    Please Login or Register  to view this content.

  6. #6
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Delete cell values with Date function in vba

    Quote Originally Posted by mehmetcik View Post
    Please Login or Register  to view this content.
    You can also do the above part of your code with just a single call to the SpecialCells function...
    Please Login or Register  to view this content.
    Last edited by Rick Rothstein; 02-05-2020 at 02:47 PM.

  7. #7
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Delete cell values with Date function in vba

    Thanks Rick

    I have previously tried all manner of solutions without success.

  8. #8
    Registered User
    Join Date
    12-26-2019
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    69

    Re: Delete cell values with Date function in vba

    Hi Rick, thank you. This has solved my issue. Thank you so much. Reps on the way.

+ 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. Double Click Cell to add date - or delete date
    By COL_MCC in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-25-2019, 04:54 AM
  2. Macro to find Date Cells > Current Date and delete everything to left of that cell
    By LewisLonsdale in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-25-2015, 06:36 AM
  3. Replies: 3
    Last Post: 11-23-2013, 06:21 AM
  4. [SOLVED] Extract date from cell and replace value with date then delete empty rows
    By jjislas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-03-2013, 11:52 AM
  5. if cell is wrapped with IFERROR function, then delete the function from the cell
    By Shishek in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-20-2012, 07:21 PM
  6. Delete Unique Values after Date X
    By randell.graybill in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-07-2009, 04:26 AM
  7. [SOLVED] Function to find duplicate values, then delete
    By Cam in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-26-2006, 09:40 PM

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