+ Reply to Thread
Results 1 to 3 of 3

Average column

  1. #1
    Registered User
    Join Date
    03-04-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    40

    Average column

    As always, it got to 17.00 and I clicked something and lost a working Macro that I now cannot replicate.

    I am trying to write a macro for a series of spreadsheets where the column I wish to average (same in each) has varying numbers of rows.

    As a very amateur VBA writer, I managed to record a Macro and edit the values (xlDown) so it that looked at a larger range depending on how many rows in the data.

    The whole macro converts dates stored as text to numerical value, then copy and pastes it to 'dd/mm/yy hh/mm/ss' then averages associated data in a column F.
    The section of macro I broke was along the lines of:

    "Range("F2").Select
    ActiveCell.FormulaR1C1 = "=AVERAGE(RC[-2]:R[End(xlDown)]C[-2])"
    Range("F2").Select
    ActiveWindow.SmallScroll Down:=-18"

    I cannot remember exactly what I put in as the R[End(xlDown)] part but it worked once and now cannot replicate... I am trying to enter in cell F2 the average of column D from D2 to the end of the column.

    Any ideas?

    Many thanks in advance.

    Damien
    Last edited by damo_uk; 01-16-2012 at 02:17 PM. Reason: SOLVED

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Marco - average column

    You can assign a variable to the lastrow of column D ...for example -
    Please Login or Register  to view this content.
    You do not require the Select statements and even the scroll down statements.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    03-04-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Marco - average column

    Thank you very much Arlette.

    Answered my query perfectly

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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