View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Using variable in WorksheetFunction

If you used =countif() in the cell, your formula would be:

=countif(sheetx!b2:b###,"$a$2:$a85")

This doesn't look like it's what you really want.



Mike Fogleman wrote:

Can you see what I am doing wrong here.

Sub CntIf()
Dim myrng As Range

Sheets("Node Data").Activate
Cells(1, counter + 2).Value = "Total Leaks per " & Ldb
Set myrng = Sheets(Ldb).Range("B2:B" & rwct)
Range(Cells(2, counter + 2), Cells(85, counter + 2)) =
Application.WorksheetFunction.CountIf(myrng, "$A$2:$A$85")

End Sub

This does put values in the range (Cells(2, counter + 2), Cells(85, counter
+ 2)) , but they are all 0's, not the correct count.

TIA
Mike F


--

Dave Peterson