+ Reply to Thread
Results 1 to 5 of 5

Code - monthly portfolio update

  1. #1
    Registered User
    Join Date
    06-11-2007
    Posts
    46

    Code - monthly portfolio update

    Hi all, I have a document that lists the accounts of my company's portfolio. I want to write a macro that copies the fund balances and percentage of total portfolio, and paste that information in another sheet where I am putting all my end-of-the-month values.

    The funds are listed in sheet "Details" in A3:A22. The current balances for the individual funds in C3:C22. The current % of total portfolio of each fund is in D3:D22.

    The historical balances are listed in sheet "Historical Balances". Each month, I want to paste as values the cells Details!B3:C22 into the next available column in the sheet "Historical Balances", and starting the 3rd row down (so, for the next month, the data will be pasted in Historical Data!F3:F22).

    Here's the code I have written so far:

    Please Login or Register  to view this content.
    The code hasn't worked, and is now giving me a Run Time Error 9 Subscript Out of Range. Can anyone see what's wrong with my code? Thanks!

  2. #2
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127
    I didn't really have a chance to check the code entirely, but this line seems suspect:

    Please Login or Register  to view this content.
    It will likely be a problem because iCountCol + 1 is a number. For example, if iCountcol = 10, your code would be:

    Please Login or Register  to view this content.

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525
    Quote Originally Posted by nhrav
    Hi all, I have a document that lists the accounts of my company's portfolio. I want to write a macro that copies the fund balances and percentage of total portfolio, and paste that information in another sheet where I am putting all my end-of-the-month values.

    The funds are listed in sheet "Details" in A3:A22. The current balances for the individual funds in C3:C22. The current % of total portfolio of each fund is in D3:D22.

    The historical balances are listed in sheet "Historical Balances". Each month, I want to paste as values the cells Details!B3:C22 into the next available column in the sheet "Historical Balances", and starting the 3rd row down (so, for the next month, the data will be pasted in Historical Data!F3:F22).

    Here's the code I have written so far:

    Please Login or Register  to view this content.
    The code hasn't worked, and is now giving me a Run Time Error 9 Subscript Out of Range. Can anyone see what's wrong with my code? Thanks!
    Lets see the workbook with the code, you do not tell us where the error occurs....

  4. #4
    Registered User
    Join Date
    06-11-2007
    Posts
    46
    About where the error occurs, I did not have any idea. Normally I program in Excel 2003, but yesterday I was using 2007. Maybe the settings were different or something, but it never showed which parts of the code needed to be debugged.

    I changed the file format to 1997-2003 compatible, and the code worked! I modified it a little, and this is what I have now:

    Please Login or Register  to view this content.
    Would anybody be able to tell me why the code did not work in the Excel 2007 format, but did work in the 2003 format? We are switching over to 2007 versions, and I don't want to have to go through these problems again.

  5. #5
    Registered User
    Join Date
    06-11-2007
    Posts
    46
    Forgot to add, thanks for all the help so far!

+ 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