#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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 ("He " & 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


--
PGalla06
------------------------------------------------------------------------
PGalla06's Profile: http://www.excelforum.com/member.php...o&userid=24260
View this thread: http://www.excelforum.com/showthread...hreadid=381238

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Totals


Here's a simplified version of your code.
You can use one SumString and just add it to itself repeatedly.


Code:
--------------------
Sub Totals()

Dim Start As String
Dim EndPart As String
Dim Spacer As Integer
Dim SumString 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? ")
SumString = "=R[-4]C"
For Counter = 2 To Num
Argument = Counter * Spacer
SumString = SumString & "+" & Start & Argument & EndPart
Next Counter
MsgBox ("He " & SumString)
End Sub
--------------------


HTH


--
bhofsetz
------------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...o&userid=18807
View this thread: http://www.excelforum.com/showthread...hreadid=381238

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Totals


bhofsetz,

You're awesome!

Thanks,

Peter


--
PGalla06
------------------------------------------------------------------------
PGalla06's Profile: http://www.excelforum.com/member.php...o&userid=24260
View this thread: http://www.excelforum.com/showthread...hreadid=381238

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivot Totals: Group totals different from Grand totals PsyberFox Excel Discussion (Misc queries) 1 February 13th 08 06:16 PM
how to enter totals and sub totals from receipts into excel. mjd23 New Users to Excel 2 January 11th 08 01:54 AM
Summing Weekly Totals into Monthly Totals steph44haf Excel Worksheet Functions 3 July 5th 06 04:51 PM
How do I sum YTD totals based on monthly totals Bsgrad02 Excel Discussion (Misc queries) 3 July 12th 05 04:59 PM
Comparing/matching totals in a column to totals in a row Nicole L. Excel Worksheet Functions 3 January 27th 05 10:42 PM


All times are GMT +1. The time now is 01:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"