arsenalgkjono
New Member
- Joined
- Sep 13, 2011
- Messages
- 1
Here is the code, for some reason I am getting a next without for error. What is wrong with it?
Sub MeanCEOAge()
'
' MeanCEOAge Macro
'
Dim TotalAge As Integer
Dim CEOcount As Integer
Dim i As Integer
TotalAge = 0
CEOcount = 0
For i = 2 To 51
If Cells(i, 5).Value = "CEO" Then
CEOcount = CEOcount + 1
TotalAge = TotalAge + Cells(i, 3).Value
If Cells(i, 5).Value = "CEO/President" Then
CEOcount = CEOcount + 1
TotalAge = TotalAge + Cells(i, 3).Value
If Cells(i, 5).Value = "CEO/Chairman" Then
CEOcount = CEOcount + 1
TotalAge = TotalAge + Cells(i, 3).Value
End If
Next i
Cells(11, 8) = CEOcount
Cells(11, 7) = TotalAge
'
End Sub
Sub MeanCEOAge()
'
' MeanCEOAge Macro
'
Dim TotalAge As Integer
Dim CEOcount As Integer
Dim i As Integer
TotalAge = 0
CEOcount = 0
For i = 2 To 51
If Cells(i, 5).Value = "CEO" Then
CEOcount = CEOcount + 1
TotalAge = TotalAge + Cells(i, 3).Value
If Cells(i, 5).Value = "CEO/President" Then
CEOcount = CEOcount + 1
TotalAge = TotalAge + Cells(i, 3).Value
If Cells(i, 5).Value = "CEO/Chairman" Then
CEOcount = CEOcount + 1
TotalAge = TotalAge + Cells(i, 3).Value
End If
Next i
Cells(11, 8) = CEOcount
Cells(11, 7) = TotalAge
'
End Sub