+ Reply to Thread
Results 1 to 3 of 3

Thread: Do Loop Help

  1. #1
    Registered User
    Join Date
    06-03-2009
    Location
    N.Ireland
    MS-Off Ver
    Excel 2003
    Posts
    76

    Do Loop Help

    I am trying to create a macro to loop through a column (column A) with a persons dob and output their age in (column B). I have a basic formula that already calculate the age:

    =DATEDIF(Y2,TODAY(),"y").

    I have got an example of a loop (calulates average) to do this but im unsure of how to add my formula to it:

    Code:
    Sub calculateAge()
    
        Do
    
        ActiveCell.FormulaR1C1 = "=Average(RC[-1],RC[-2])"
    
        ActiveCell.Offset(1, 0).Select
    
        Loop Until IsEmpty(ActiveCell.Offset(0, 1))
    
    End Sub


    Can anyone help?
    Last edited by PRodgers; 06-09-2009 at 09:34 AM.

  2. #2
    Forum Guru mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,984

    Re: Do Loop Help

    Please take a couple of minutes and read ALL theForum Rules then wrap your VBA code (Rule 3)
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Registered User
    Join Date
    06-03-2009
    Location
    N.Ireland
    MS-Off Ver
    Excel 2003
    Posts
    76

    Re: Do Loop Help

    Quote Originally Posted by mudraker View Post
    Please take a couple of minutes and read ALL theForum Rules then wrap your VBA code (Rule 3)

    Appologies for that, post has been edited

Thread Information

Users Browsing this Thread

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

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.2.0