View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Mike Fogleman Mike Fogleman is offline
external usenet poster
 
Posts: 1,092
Default Using variable in WorksheetFunction

This formula pasted in the activesheet from B2:B85 works. There is a list of
unique items in this sheet from A2:A85 that I want counted from the sheet
LAFQ403 B2:B568.

=COUNTIF(LAFQ403!B2:B568,$A$2:$A$85)

The variable Ldb="LAFQ403"
rwct=568, so myrng = Sheets(Ldb).Range("B2:B" & rwct)
counter=0 so Range(Cells(2, counter + 2), Cells(85, counter + 2)) is
Range("B2:B85") of the activesheet.

How, in VB, do I get the results of the COUNTIF into the range B2:B85 of the
activesheet?
I have never figured out how to put variables into a cell formula =
"=CountIf(myrng), so I am trying the Application.WorksheetFunction method,
but still coming up zip.
As it turns out "0" is the correct count for the first item in A2, so it is
giving me one answer throughout the entire range.