CDTech
04-29-2010, 10:53 AM
Hello all.
Can anyone tell me why this works
Worksheets(sThisSample).Activate
Application.Range("A1").Activate
'Count returns long data type, cast to integer.
iAnswer = CInt(WorksheetFunction.Count(Worksheets(sThisSample).Range("A2:A8000")))
yet this doesn't
Worksheets(sThisSample).Activate
Application.Range("A1").Activate
'Count returns long data type, cast to integer.
iAnswer = CInt(WorksheetFunction.Count("A2:A8000"))
I assume since worksheet sThisSample is in scope, the count function will use the range A2:A8000 on that worksheet. It works fine in an earlier section of code where the starting sheet is active.:dunno
Can anyone tell me why this works
Worksheets(sThisSample).Activate
Application.Range("A1").Activate
'Count returns long data type, cast to integer.
iAnswer = CInt(WorksheetFunction.Count(Worksheets(sThisSample).Range("A2:A8000")))
yet this doesn't
Worksheets(sThisSample).Activate
Application.Range("A1").Activate
'Count returns long data type, cast to integer.
iAnswer = CInt(WorksheetFunction.Count("A2:A8000"))
I assume since worksheet sThisSample is in scope, the count function will use the range A2:A8000 on that worksheet. It works fine in an earlier section of code where the starting sheet is active.:dunno