VBA Code to calculate CURRENT DATE - COLUMN DATE and insert the difference in Another Column

Jabes7

New Member
Joined
Jul 13, 2012
Messages
12
Hi Mates,

I need a Piece of VBA Code to calculate CURRENT DATE - COLUMN(A) DATE and enter the days in Column B

Tried with Date Diff Function. But Dont know how exactly to do. :confused:

Thanks in Advance :)
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Thanks Joe,

It Works Fine like NOW()-A1 . But What i need is, Some rows in my A Column has null value. Excel Considers it as Year 2122 and formulates 41000 days in my col B. Suggest a Solution.

Thanks in Advance!
 
Upvote 0
Wonderful Ingolf.

Okay the value is displayed. Now the Issue is, the value displayed as 17.93 . I need only the count of days. So, if i remove the precisions through 'format cells option' it getting rounded to 18 .

Please, Guide me how to display the value 17 alone even if its 17.99
 
Upvote 0
Hello,

I think using the function Now () not TODAY () the result is with decimal. Anyway try

= INT (IF (OR (A1 = "", A1 = 0), "", NOW ()-A1))
or this
= FLOOR (IF (OR (A1 = "", A1 = 0), "", NOW ()-A1), 1)
 
Upvote 0
Nicely done friend.

It works fine. Adding to that, now my requirement is if A1>Currentdate it should not calculate. I modified and used your code as
Code:
=INT(IF(OR(A!="",A1>NOW()),"",NOW()-A1))

And i used FLOOR Function. Both INT and FLOOR Function Displays ' #VALUE! ' when A1>Currentdate. Kindly fix friend!



Hello,

I think using the function Now () not TODAY () the result is with decimal. Anyway try

= INT (IF (OR (A1 = "", A1 = 0), "", NOW ()-A1))
or this
= FLOOR (IF (OR (A1 = "", A1 = 0), "", NOW ()-A1), 1)
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top