Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sum variable ranges
Two part question:
I have a spreadsheet where I want to sum one of a few ranges. E15 will contain the sum of E7:E14. Then E30 will contain the sum of E17:E29 and so on. This is part of a loop function where the code loops through the sheet and when it hits "Progam Total", it assignes the the formula in question. Here is the current code: Sub Totals() Dim Client As Range Dim Spend As Range Dim Sales As Range Set Client = Sheet1.Range("C7") Set Spend = Sheet1.Range("E7") Set Sales = Sheet1.Range("F7") Do Until ActiveCell = "STOP" If Client = "Program Total" Then Spend = FORMULA TO ADD THE VARIABLE RANGE Sales = FORMULA TO ADD THE VARIABLE RANGE Client = Client.Offset(1, 0).Select Spend = Spend.Offset(1, 0).Select Sales = Sales.Offset(1, 0).Select Else Client = Client.Offset(1, 0).Select Spend = Spend.Offset(1, 0).Select Sales = Sales.Offset(1, 0).Select End If End Sub Second Question: Is there a better way to do this? My experience is that there always is... Thanks! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Named ranges scope / workbook/worksheet level named ranges- changeswith variable use... | Excel Programming | |||
Variable Ranges | Excel Worksheet Functions | |||
Variable ranges | Excel Programming | |||
Counting variable ranges and auto-summing variable ranges | Excel Programming | |||
Variable ranges | Excel Worksheet Functions |