# code that will check the date from a table if its MM/YY is current and if not then date=YY

1. ## code that will check the date from a table if its MM/YY is current and if not then date=YY

When Year in Year/month column is current then retain Year/Month value, if year in Year/Month column is prior year then Year/Month2 = Year.

 Year/Month Year/Month2 2014/May 2013/april 2014/jan

2. ## Re: code that will check the date from a table if its MM/YY is current and if not then dat

Originally Posted by richzter
When Year in Year/month column is current then retain Year/Month value
Not sure what do actually mean by the word retain

3. ## Re: code that will check the date from a table if its MM/YY is current and if not then dat

Originally Posted by :) Sixthsense :)
Not sure what do actually mean by the word retain
sorry.. it means that if the yy/mm is current then Year/Month=yy/mm

4. ## Re: code that will check the date from a table if its MM/YY is current and if not then dat

if the 1st column is 2014/May then 2nd column is 2014/may
if its 2013/june then 2nd column is 2013

5. ## Re: code that will check the date from a table if its MM/YY is current and if not then dat

Your condition part is very clear in your first post itself but wants to know the action part only...

6. ## Re: code that will check the date from a table if its MM/YY is current and if not then dat

Originally Posted by :) Sixthsense :)
Your condition part is very clear in your first post itself but wants to know the action part only...
im sorry what do you mean by action part?

7. ## Re: code that will check the date from a table if its MM/YY is current and if not then dat

Better show the expected result for Year/Month2 column for the given examples for giving exact solution

8. ## Re: code that will check the date from a table if its MM/YY is current and if not then dat

 Year/Month Year/Month2 2014/May 2014/May 2013/april 2013 2014/jan 2014/jan

uhmm.. if i may add.. do you know a code that will not rely on the cell name? but for the column name or ranges.. so that if the user suddenly enters another column.. the codes wont be rendered useless..

9. ## Re: code that will check the date from a table if its MM/YY is current and if not then dat

Don't know the real need for VBA here... what about a simple formula solution?

In B1 Cell

=IF(LEFT(A2,4)=TRIM(YEAR(TODAY())),A2,LEFT(A2,4))

Drag it down...

10. ## Re: code that will check the date from a table if its MM/YY is current and if not then dat

Originally Posted by :) Sixthsense :)
Don't know the real need for VBA here... what about a simple formula solution?

In B1 Cell

=IF(LEFT(A2,4)=TRIM(YEAR(TODAY())),A2,LEFT(A2,4))

Drag it down...
yeah thanks.. but what if the user suddenly adds a column...

11. ## Re: code that will check the date from a table if its MM/YY is current and if not then dat

Originally Posted by richzter
yeah thanks.. but what if the user suddenly adds a column...
The target cell will not get changed and it will target the source cell always.

If you want to set it to a new column then just change the source column name (in the formula) to your newly created column.

Pleaes let me know if you want something else...

12. ## Re: code that will check the date from a table if its MM/YY is current and if not then dat

Originally Posted by :) Sixthsense :)
The target cell will not get changed and it will target the source cell always.

If you want to set it to a new column then just change the source column name (in the formula) to your newly created column.

Pleaes let me know if you want something else...
uhmm.. 1 last thing.. can you explain how it works?

13. ## Re: code that will check the date from a table if its MM/YY is current and if not then dat

Originally Posted by :) Sixthsense :)
The target cell will not get changed and it will target the source cell always.

If you want to set it to a new column then just change the source column name (in the formula) to your newly created column.

Pleaes let me know if you want something else...
please explain how it works.. so i know how to use it next time.. thanks

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### 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