I am trying to loop through a worksheet and calculate four (4) percentages. At the end of each loop I need to move to the next row and do the same calculations for the new row and so on. I assume that if the myRange is assigned a new value (for the next range) no changes to the functions that do the calculation need to be made because their references to other cells are relative to the new value of myRange or am I wrong, again?
Though the right cell is selected an Error 424 (Object required) is raised at the statement; “Set myRange = myRange.Offset(1, 0).Select”
The variable myRange is dimensioned in the General Declearations.
Can someone suggest what I am doing wrong?
Here’s my code:
Sub CalculatePercents()
Dim myStop As Integer, myCount As Integer
'Determines the number of records (rows) and assigns _
value to variable.
myStop = Range("A1"
.CurrentRegion.Rows.Count
'Range("CB4"
.Select
Set myRange = Range("CB4"
'Counter needed to end looping.
myCount = 1
'Do Until myStop = myCount
'Calculates funding percentages for a row.
Call GeneralFundPercent
Call SpecialFundPercent
Call TotalFedFunds
Call FederalFundPercent
Call TotalPercent
'Moves next row.
Set myRange = myRange.Offset(1, 0).Select
'Counter
myCount = myCount + 1
'Loop
End Sub
Though the right cell is selected an Error 424 (Object required) is raised at the statement; “Set myRange = myRange.Offset(1, 0).Select”
The variable myRange is dimensioned in the General Declearations.
Can someone suggest what I am doing wrong?
Here’s my code:
Sub CalculatePercents()
Dim myStop As Integer, myCount As Integer
'Determines the number of records (rows) and assigns _
value to variable.
myStop = Range("A1"
'Range("CB4"
Set myRange = Range("CB4"
'Counter needed to end looping.
myCount = 1
'Do Until myStop = myCount
'Calculates funding percentages for a row.
Call GeneralFundPercent
Call SpecialFundPercent
Call TotalFedFunds
Call FederalFundPercent
Call TotalPercent
'Moves next row.
Set myRange = myRange.Offset(1, 0).Select
'Counter
myCount = myCount + 1
'Loop
End Sub