+ Reply to Thread
Results 1 to 3 of 3

Delete if older than 3 months and offsetting a cell input if match found

  1. #1
    Forum Contributor
    Join Date
    08-10-2014
    Location
    Alberta
    MS-Off Ver
    2016
    Posts
    128

    Delete if older than 3 months and offsetting a cell input if match found

    Hello, I have two questions, but they pertain to the same page. The rules do not state you cannot ask two questions, but I can see how that may be confusing, so perhaps it should be added(?).

    The first one is to delete a row of cells to the left if one column has an older date than today. The cell "P1" has =Today() in it, but it does not seem to work. What do I have incorrect? Here is the code:
    Please Login or Register  to view this content.
    The second issue is with offsetting a cell if the name is found in column 1. I have no idea on how to do this without entering it on a userform first. The difficult part is that it is on two different pages. So if another cell that is in Cell.Row, 2 has O/N in the row in ws1 and has the same name in ws2 already, then I want it to go into the next column, which is 3. This needs to be done until it gets to column 6. These cells in the new columns need to have DateAdd("d", -1, Date) in them. Here is the code I already have.

    Please Login or Register  to view this content.
    Here is what it looks like:
    Untitled.jpg
    With the dates being offset for Bob if there is another O/N.
    Last edited by Templemind; 09-27-2014 at 02:46 AM.

  2. #2
    Forum Contributor
    Join Date
    09-26-2014
    Location
    Moscow, Russia
    MS-Off Ver
    MSE 10, MSE 13
    Posts
    179

    Re: Delete if older than 3 months and offsetting a cell input if match found

    Hello, Templemind.

    About your first question. I recommend you something like code below.

    1). It is not proper to use "Cell" word as variable, because Excel already have such object. "CellX" will be fine.
    2). When you point a sheet with "With" method - you need to do it according to programm grammar. Example down below will be correct. If you will name the sheet you need as "NameOfSheet", ofcourse. Or replace "NameOfSheet" with a proper name.
    3). When you want to connect "With [Object]" with something, you need to write "." before it. In case "Cells(1, 1)" will refer to an active sheet and ".Cells(1, 1)" will refer to sheet you need.
    4). ".Cells(1, "P")" against ".Cells(1, 16)" - just my habit, don't mind =)
    5). When you are comparing cells, you need to say what parameters of them you are comparing. Width? Height? Or, may be, color number? I'll guess it's value parameter we need this time.
    6). You may clear all near standing cells in a single strike. I used Offset() to point top left cell and by Resize() I showed to programm how much do we need. But it will only clear your cells. If you want for a whole row to get out of your document - you will need slightly different commands and objects. Let me know, if it is the case.
    7). I introduced variables to the program by "Dim"ing them. Just programming courtesy. In case, if you introduced them earlier in your code - you will need to correct this part.

    Please Login or Register  to view this content.
    Best wishes.
    Last edited by Rioran; 09-27-2014 at 07:05 AM. Reason: Grammar

  3. #3
    Forum Contributor
    Join Date
    08-10-2014
    Location
    Alberta
    MS-Off Ver
    2016
    Posts
    128

    Re: Delete if older than 3 months and offsetting a cell input if match found

    Thank you for that detailed lesson. It helps me make my code a little nicer and to learn how to write it in the future.

    It worked for my purposes. I do not need to delete the entire row, just those cells. I also changed the variables I had before. Thank you.

+ 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] Match Cell Content and Delete Cell Content If a Match is Found
    By aviatecar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-30-2013, 01:29 PM
  2. [SOLVED] Match one cell with another, if match found copy adjacent cells
    By Xiophoid in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-07-2013, 05:50 AM
  3. Replies: 6
    Last Post: 05-24-2012, 09:14 AM
  4. Compare two sheets and delete row if match found
    By Steinwall in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-13-2011, 03:25 PM
  5. Regression - Having trouble offsetting input/output references
    By emadden in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-15-2009, 04:38 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