I am looping thru and getting a count of values in an array for a specific
user in a single row range. I switch to another range and add in the value
fro that rnage
Here is the code:
If Evaluate("ISREF('" & "Game" & i & "'!A1)") Then
Set ws = ThisWorkbook.Sheets("Game" & i)
Else
Set ws = ThisWorkbook.Sheets("Games")
End If
With ws
'for each game get the range for the names
'Provide the correct range for the specific Game
Set Rng = .Range("Game" & i)
r = Rng.Row
C = Rng.Column
iRows = Rng.Rows.Count
iCols = Rng.Columns.Count
'need to lop thru each player in the grid, get values if match
For p = 1 To iRows
'get value if name matches
sName = .Cells(r + p - 1, C)
If sName = Player Then
'add up
sPos = "=" & Position
Set RngPlayerGame = .Range(.Cells(r + p - 1, C),
.Cells(r + p - 1, C + iCols))
iCount = iCount + ws.Evaluate("COUNTIF(RngPlayerGame,"
& Chr(34) & "=B" & Chr(34) & ")") '.Evaluate("=COUNTIF(.Cells(r + p - 1,
C), .Cells(r + p - 1, C + iCols) ,Chr(34) & ='& Position)")
End If
Next
It does run, no errors, but returns a value of 0 which is incorrect.
Answer is 1, then 2, then 1,1,2,1 for the first player.
But if I use :
'=COUNTIF(B3:G3,"=B")
I get the correct value. CLearly I need to use parameters and fnot hard
code.
In advance - THANK YOU so much. This one has me by the short hairs!
jaime
--
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @
https://www.facebook.com/discussexcel
FORUM RULES
1) Use concise, accurate thread titles. Poor thread titles, like Please Help,
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.
NOTE : Don't ever post confidential data in a workbook. Forum owners and
members are not responsible for any loss.
---
You received this message because you are subscribed to the Google Groups "MS
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.