Hi im looking for some help on a loop i've been trying to work out. Its only for a football prediction spreadsheet.
Basically i have rows of peoples name where the guess the result and the score.
then i have the first 2 rows as the actual result and score.
I've created a function to calculate it but i need to loop through each row in ranges to add up the totals.
`ResultRange = Range("B2", Range("A2").End(xlDown)).Rows.Count
ScoreRange = Range("C2", Range("C2").End(xlDown)).Rows.Count
GuessResRange = Range("D2", Range("D2").End(xlDown)).Rows.Count
GuessScoreRange = Range("E2", Range("E2").End(xlDown)).Rows.Count
Range("B14").Value = ScorePoints(InResultRows, InScoreRows, InGuessResult, InGuessScore)
This is what I have so far.
Basically for 10 games ResultRows, ScoreRows, GuessResult, GuessScore
would go from B2,C2,D2,E2 to B3,C3,D3,E3 and so on until it hits the end of the scores. Then the total would be tallied up in Range B14. Then continuing this onto the next player?
Still a bit unclear about what you're trying to do, but this might get you started:
Sub FootballPredict()
Dim GuessResRange As Range
Dim rngLoop As Range
Dim dblSum As Double
Set GuessResRange = Range("B2", Range("B2").End(xlDown))
' For Each rngLoop In GuessResRange
' 'could use this loop to do something
' Next rngLoop
dblSum = WorksheetFunction.Sum(GuessResRange)
Range("B14").Value = dblSum
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.