Thread: For Each Next
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone[_2_] Jim Cone[_2_] is offline
external usenet poster
 
Posts: 1,549
Default For Each Next

"Cell" isn't declared - use "Option Explicit" as the first line in the module.

For Each Cell in Sheets("Scoreboard").Range("B:I") - returns a Column not a Cell.

For Each Cell in Sheets("Scoreboard").Range("B2:I2").Cells - returns a Cell
--
Jim Cone
Portland, Oregon USA
http://www.mediafire.com/PrimitiveSoftware
(free and commercial excel programs)




"Vacuum Sealed"
wrote in message nd.com...
Hi all

Still can't get my head in the right place regarding the subject matter.

I am trying to set up a scoreboard of sorts.

The idea is that if there is a Team Name ( tName ) in Column A then look at the Team Score (
tScore ) range and for every Cell in ( tScore ) that's back color = 65535 then that Cells value is
doubled.

Then the Team's Total will be a Sum of the row that fits within the ( tScore ) range.

the below falls into the N.Q.R. category

Sub Update_Score()

Dim tScore As Range, tTotal As Range
Dim tName As Range
Dim i As Integer

For i = 2 To 32

Set tName = Sheets("Scoreboard").Range("A:A")
Set tScore = Sheets("Scoreboard").Range("B:I")
Set tTotal = Sheets("Scoreboard").Range("J:J")

If Cells(i, tName).Value < "" Then
For Each Cell In tScore
If Cells(i, tScore).Interior.Color = 65535 Then
Cells(i, tScore).Value = Cells(i, tScore).Value * 2
Cells(i, tTotal).Value = WorksheetFunction.Sum(i, tScore)
Next Cell
Else
Exit For
End If
End If

Next i

End Sub

As always your assistance is most appreciated

TIA
Mick.