View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default using countif from a vba macro

You changed GB's formula.

Watch those double quotes and try again.

But you could get it all at once and skip the looping:


Range("T4:T1443").Formula = "=IF(COUNTIF($H$4:$H$1443,H4)=1,H4)"

christopher ward wrote:

hi all - many thanks for trying to help but i still am failing - my sheet now
shows the following in colum V

#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?
#NAME?

the code i run is like this

Sub spot_duplicates()

'For I = 4 to X <- Where X is the last row you want to include data
' Range("T"&I).Formula = "=IF(COUNTIF(H4:H1443,H4)=1,H"&I&")"
'Next i

Dim cell As Range
Dim i As Integer

Sheets("Data").Select
Range("V4:V1443").Select

For i = 4 To 1443
Range("V" & i).Formula = "=IF(COUNTIF(H4:H1443,H4)=1,H&i)"
Next i

End Sub

--
C Ward

"Yngve" wrote:

Hi christopher

Start recording macro and put the formula in the cell.
Stop recordig an goto VB/prodject/Modul, ther you will find the
macro

Regards Yngve



--

Dave Peterson