+ Reply to Thread
Results 1 to 8 of 8

VBA MACRO To Calculate Dates

  1. #1
    Registered User
    Join Date
    09-29-2014
    Location
    Dallas, TX
    MS-Off Ver
    2010
    Posts
    45

    VBA MACRO To Calculate Dates

    Hi,

    I'm in desperate need of helps with a couple of dates. In short, I have dates in Column A. In D3, I enter a formula to add 5 days to A3's date & copy the formula down. In E3, I enter a formula to calculate one month from A3's date and copy it to the 2nd to last cell of column E. E2 require manual input and the last cell of E must = A's last cell data .

    Once I do this, I run a macro that works fine. However, it defeats the purpose to have a macro, if I am doing manual things to run it.

    So, I'd like to add the formula d3=A3 + 5 into my exiting macro loop down column d. Then, add the formula e3=edate(A3,1) loop down column e. See the attached and thanks in advance for your help!

    Attachment 389932

    here's the bigger challenge the last data cell on E will always equals A's but A call be 3 rows or 30000. So, I can't put an fixed formula like E12=A12 as there will be times its more than 12
    Attached Files Attached Files
    Last edited by lashellr; 04-18-2015 at 10:05 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: VBA MACRO To Calculate Dates

    Hi lashellr
    Is this the sort of thing you need? It uses inputboxes for you to enter data in & then runs the macro. when finished it
    deletes the contents of B12 E2 & E12. It does it once & the macro exits
    You say that A3 can have 3-30000 dates. How does that work?

    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: VBA MACRO To Calculate Dates

    crosspost: http://www.ozgrid.com/forum/showthread.php?t=194259

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Registered User
    Join Date
    09-29-2014
    Location
    Dallas, TX
    MS-Off Ver
    2010
    Posts
    45

    Re: VBA MACRO To Calculate Dates

    Wanted-Help (1).xlsm

    I revised my attachment to make it clear. The prompt in E2 works great. I don't want to auto erase the input when done, as I will create a separate 'clear sheet macro.'

    I really just want to add the formula D3=A3+5 & E3=EDATE(A3,1) into my macro and have them loop down the respective columns, since I don't always know how many dates A will have.

    I lost all hope of figuring out how to make the cell of A=E, since it can be A19 or A9000
    Last edited by lashellr; 04-18-2015 at 10:22 AM.

  5. #5
    Registered User
    Join Date
    09-29-2014
    Location
    Dallas, TX
    MS-Off Ver
    2010
    Posts
    45

    Re: VBA MACRO To Calculate Dates

    Thanks for the help Alan, didn't know about the rule. Since I received no help there, I came here. Won't forget the link next time

  6. #6
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: VBA MACRO To Calculate Dates

    Now I'm aware of it, I've had a look at the other thread & see there's no answer as yet.

    Try this attempt. I used the bottom used row of column A as a reference for the last cell in column E.
    I notice you deleted the code for the bottom cell on column B, so I've left it that way. I presume you're going to be manually
    entering data to the same row as the bottom of column A. If you don't & because you've used column B for your loop,
    your loop won't do every used row in the other columns.
    Added a bit of error checking to the Inputboxes. Formatted columns D&E as mm/dd/yyyy. Change to General if you want numbers
    instead of dates.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    09-29-2014
    Location
    Dallas, TX
    MS-Off Ver
    2010
    Posts
    45

    Re: VBA MACRO To Calculate Dates

    OMG, you are a genius!? This is exactly what I wanted. Thank you sooo much for all your help and hard work (as that code far exceeds anything I am capable of)! Definitely added a reputation.

  8. #8
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: VBA MACRO To Calculate Dates

    No problem

+ 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] COUNTIFS between 2 dates - how to calculate for blank dates
    By HeyInKy in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-13-2014, 12:03 AM
  2. [SOLVED] Create Macro to Calculate Workdays Between two Dates
    By boldcode in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-07-2013, 05:06 PM
  3. Replies: 1
    Last Post: 11-01-2012, 03:41 PM
  4. How do I calculate an age from 2 dates?
    By UMMY in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  5. [SOLVED] How do I calculate dates?
    By MKChick in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-15-2005, 12:06 PM

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