+ Reply to Thread
Results 1 to 11 of 11

Macro for normalization

  1. #1
    Registered User
    Join Date
    08-03-2010
    Location
    Philadelphia
    MS-Off Ver
    Excel 2003
    Posts
    6

    Macro for normalization

    I have a column(A) with 20 numbers and I want to create a macro that automatically divides each number in the column by the first number and inserts these number in column B. Also, within this macro I would like to automatically plot a line chart of the normalized column as well as display the coefficient of determination of the linear regression line.

    Thanks
    Last edited by lord12; 08-03-2010 at 04:08 PM.

  2. #2
    Registered User
    Join Date
    08-03-2010
    Location
    Philadelphia
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Macro for normalization

    any tips as to where to begin?

  3. #3
    Registered User
    Join Date
    07-01-2010
    Location
    Portland, OR, USA
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: Macro for normalization

    Is this what you're after?

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    08-03-2010
    Location
    Philadelphia
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Macro for normalization

    Thanks for your help! How would i display the trendline and the y= mx+b equation, as well as the coefficient of determination?

  5. #5
    Registered User
    Join Date
    07-01-2010
    Location
    Portland, OR, USA
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: Macro for normalization

    Try recording those desired changes, and then pasting that code into the end of what I've given you.

  6. #6
    Registered User
    Join Date
    08-03-2010
    Location
    Philadelphia
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Macro for normalization

    I modified the code in another way. I want to find the 3 day "moving average" for the normalized column. I need help with syntax for SUM. In terms of displaying the coefficient of determination and the equation for the linear regression line, here is my attempt at coding this.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    07-01-2010
    Location
    Portland, OR, USA
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: Macro for normalization

    I'm not sure about Excel 2003, but in 2007 you can add multiple trendlines... there is an option for a Moving Average trendline as well, with an adjustable period.

    Are you able to record the Moving Average trendline and add it the same way you added the linear one?

  8. #8
    Registered User
    Join Date
    08-03-2010
    Location
    Philadelphia
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Macro for normalization

    This is my final code. One question I have, however, is how do you determine the length of a column? If I want to find the number of entries in column A, how would I do this without a for loop. Also, whenever I save this as a macro excel workbook, whenever I open it back up I cannot access my module. Why is this?


    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    08-03-2010
    Location
    Philadelphia
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Macro for normalization

    Can anyone help?

  10. #10
    Forum Contributor
    Join Date
    03-11-2010
    Location
    India
    MS-Off Ver
    2010
    Posts
    268

    Re: Macro for normalization

    Please Login or Register  to view this content.
    will return the number of entries in column A

    hth
    Ajay

  11. #11
    Registered User
    Join Date
    07-01-2010
    Location
    Portland, OR, USA
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: Macro for normalization

    You can use one of the following lines of code:

    Please Login or Register  to view this content.
    The first one will count how many cells are in column A. If you have data in rows 1-20, but you have a blank cell in row 10, then it will return 19.

    The second one tells you the lowest used row in column A. So in the above scenario it would still tell you 20. It would probably be better for your purposes.

    I'm still not sure why you need to do the part with the sum and divide by 3; doesn't the moving average trendline do the same thing? Try this code:

    Please Login or Register  to view this content.
    Or, if you want both trendlines in one chart, that can be arranged as well.

    As for not being able to access your module... what do you mean exactly? you push Alt+F11, and what do you see?

    -Joe

+ Reply to Thread

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.6.0 RC 1