View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Ben McClave Ben McClave is offline
external usenet poster
 
Posts: 173
Default Check a range to see if a value exists in it

Hi Howard,

I think there are two small changes. First, be sure to set "lData" = your data range. If it is a named range use:

Set lData = Sheet1.Range("ldata")

If it is not named, use:

Set lData = Sheet1.Range("G1:G10")

Then, change your function in the lCnt line to CountIf and drop the quotes:

lCnt = Application.WorksheetFunction.CountIf(lData, i)

Hope this helps

Ben