+ Reply to Thread
Results 1 to 3 of 3

Totals

  1. #1
    Registered User
    Join Date
    06-13-2005
    Posts
    21

    Totals

    I'm trying write a Macro that will total premium values for a porfolio of companies. The number of companies will vary from portfolio to portfolio. Here's what I have so far:

    Sub Totals()

    Dim Start As String
    Dim EndPart As String
    Dim Spacer As Integer
    Dim SumString1 As String
    Dim SumString2 As String
    Dim SumString3 As String
    Dim Argument As Integer
    Dim Counter As Integer
    Dim Num As Integer

    Spacer = 4
    Start = "R[-"
    EndPart = "]C"

    Argument = Spacer

    Num = InputBox("How many portfolio companies are there? ")

    SumString1 = "=R[-4]C"

    For Counter = 2 To Num

    Argument = Counter * Spacer

    SumString2 = "+" & Start & Argument & EndPart

    SumString3 = SumString1 & SumString2

    Next Counter

    MsgBox ("Here: " & SumString3)

    End Sub

    As you can see my sum only captures the first and last values, and I can't seem to figure out a way to incorporate all the values in the sume.

    Any help would be greatly appreciated.

    Thanks,

    Peter

  2. #2
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481
    Here's a simplified version of your code.
    You can use one SumString and just add it to itself repeatedly.

    Please Login or Register  to view this content.
    HTH

  3. #3
    Registered User
    Join Date
    06-13-2005
    Posts
    21
    bhofsetz,

    You're awesome!

    Thanks,

    Peter

+ 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